Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite and 301's

         

crxvfr

8:19 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



Am I correct in thinking that if you do a mod rewrite from an old url to a new one, its unnecessary to place a 301?

It seems to me that the handler would intercept the request and issue a request for the new url. Since it issues a request for the new url, a 301 at the old url would never be reached.

Is this correct?

jdMorgan

8:30 pm on Jun 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The question isn't clear, so maybe this will help:

You can implement an exrernal 301 redirect using mod_rewrite or mod_alias.

In addition, mod_rewrite can do an internal rewrite to 'map' a URL to a different server filepath than that which would normally be asociated with the request. This is entirely different from an external redirect, as the client is not involved.

If the server is configured to externally redirect a URL, and a request is received for that URL, then the server sends a redirect response header, providing the client with the new URL.

The only agent that issues HTTP requests is the client -- the browser or search engine robot for example. The server only responds to these client requests (like a good restaurant waiter).

So it is up to the client to re-request the desired resource from the new URL given in the preceding redirect response.

Jim

crxvfr

8:41 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



In addition, mod_rewrite can do an internal rewrite to 'map' a URL to a different server filepath than that which would normally be asociated with the request. This is entirely different from an external redirect, as the client is not involved.

Thats what I mean, if "...mod_rewrite can do an internal rewrite to 'map' a URL to a different server filepath than that which would normally be asociated with the request," ...the old url would not be fetched. If the old url is not fetched, any php 301 on it also would not be fetched.

right?

jdMorgan

3:28 am on Jun 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the server is configured correctly, so that mod_rewrite runs before the PHP interpreter, then that would be correct.

Jim