Forum Moderators: phranque

Message Too Old, No Replies

.htaccess [R] flag behaviour

         

harrybailey

1:57 pm on Sep 2, 2007 (gmt 0)

10+ Year Member



Hey all,

I have been using a .htaccess file successfully on two linux servers.
I have now moved the file to streamline hosting and am getting unexpected behaviour.

File:


RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.(realsite¦devsite)\.(net¦com)$ [NC]
RewriteCond %{REQUEST_URI}!^/(includes¦images¦js¦style)/ [NC]
RewriteRule ^(.*)$ http://www.%1.%2/includes/aFile.php?uri=%{REQUEST_URI}

Am I right in thinking that this should send all users to the file mentioned but NOT actually redirect them?
There is no [R] flag and so, as it does on the first two servers it should send the request to the file mentioned but the user should still see the original requested url?

OR am I doing something wrong?

Thank you.

jdMorgan

2:05 pm on Sep 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An external redirect is invoked either by using the [R] flag, or by including a protocol and canonical URL in the substitution URL, as documented. It sounds like your previous servers had a problem, actually.

Domain names and hostnames are essentially meaningless inside a server, once the requested domain has been resolved to a virtual host. So you should be specifying an internal server filepath to the 'space' you want to access, and not a URL.

Jim

harrybailey

2:32 pm on Sep 2, 2007 (gmt 0)

10+ Year Member



Thank you,

I now have it working using the following:


RewriteEngine on

RewriteCond %{REQUEST_URI}!^/(includes¦images¦js¦style)/ [NC]
RewriteRule ^(.*)$ /includes/aFile.php?uri=%{REQUEST_URI}

I wasn't aware a protocol (such as [)...] would also invoke a redirect.