Mobile app version of vmapp.org
Login or Join
Tiffany637

: What strings do %{HTTP_HOST} and other mod_rewrite variables return? If I have a htaccess file that has RewriteCond %{HTTP_HOST} in it, what is the HTTP_HOST? This is something I've been struggling

@Tiffany637

Posted in: #Htaccess #HttpHeaders #ModRewrite

If I have a htaccess file that has RewriteCond %{HTTP_HOST} in it, what is the HTTP_HOST? This is something I've been struggling to find out. To help me understand, could you tell me, in each example that someone might navigate to, what are the (values/responses (?) of) HTTP_HOST, REQUEST_FILENAME and THE_REQUEST? And what will a Rewrite rule actually rewrite?

www.meow.co.uk www.meow.co.uk meow.co.uk http://www.meow.co.uk/woof ("woof" is a directory) www.meow.co.uk/woof/something.html http://foo.bar.org.uk/meow ("meow" is the same directory as meow.co.uk) foo.bar.org.uk/meow/woof/something ("something" is the same html file as above)


It seems I can't log what is going on in my htaccess as I don't have access to the Apache config file.



Update

This question was put on hold as being too broad. In trying to find out how to use mod_rewrite, I often come across quite specific questions and answers here and on SO, that might be close to what I want to achieve, but leave me with no greater understanding of what the mod_rewrite variables actually are. Sure, I can figure out what the regular expressions mean, but I don't understand exactly what string they are being executed against. If I knew that, I could probably figure out exactly what I need in my .htaccess, and I'm sure others could too.

So, rant over, let's look at examples 5 and 7 above.

What strings are the result of RewriteCond %{HTTP_HOST}, RewriteCond %{REQUEST_FILENAME} and RewriteCond %{THE_REQUEST} when you're navigating to
www.meow.co.uk/woof/something.html and
foo.bar.org.uk/meow/woof/something
And, assuming you have a RewriteRule after each RewriteCond, are those same strings what the rewrite rules operate on?

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Tiffany637

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme