Jump to content

R=301 Flag Being Ignored


alex3

Recommended Posts

Hi,

 

I have this rewrite rule that detects if my VPS is being accessed via it's IP rather than an FQDN:

 

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_HOST} ^12\.123\.123\.123
        RewriteRule ^/(.*)$ http://hostname.domain.tld/$1 [R=301,L]
</IfModule>

 

And I have this as the hostname entry in my VHosts file for domain.tld:

 

<VirtualHost *:80>

        # VHost for VPS info
        ServerName hostname.domain.tld
        ServerAlias hostname.domain.tld
        DocumentRoot /home/username/www/domain.tld/public/hostname

</VirtualHost>

 

When I visit 12.123.123.123 in my browser, I get shown the index.html of the hostname dir, but I don't get a hard redirect (as I believe I should with R=301), but I still see the IP in the address bar. I can't find any reason why the flags should be ignored, so why is the RewriteRule being carried out, but the flag ignored?

 

Any help is immensely appreciated!

Cheers,

Alex

Link to comment
https://forums.phpfreaks.com/topic/196932-r301-flag-being-ignored/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.