1

I want to write a rule where I don't know the exact http_host.

For example I have (www.)?example.com. Now I need example to build the following:

(www.)?example.com/example/... in a RewriteRule.

So how can I split the http_host into name only?

1 Answer 1

1

If you need to get just the domain name, less the TLD. Then you can do something like the following:

RewriteEngine On RewriteCond %{HTTP_HOST} ^(?:www\.)?([a-z-]+)\.com [NC] RewriteRule ^$ /%1/ [R,L] 

Where %1 is just the domain name. eg. example in your example.

This assumes a TLD of .com.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.