Forum Moderators: phranque

Message Too Old, No Replies

URL Rewriting

         

bigdealioo

9:52 am on Mar 29, 2007 (gmt 0)

10+ Year Member



Is it possible to accomplish the following?

1) Surfer goes to abc.com/cat.html
2) With mod_rewrite, we change the URL that is displayed in the surfer's browser to abc.com/dog.html
3) Meanwhile.. the content being displayed is still cat.html and dog.html doesn't even exist on the server

THANKS!

jdMorgan

2:02 pm on Mar 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's certainly possible, but I suspect you may be conceptualizing the URL-to-filename translation process in reverse of the server's actual function. It seems strange to force a redirect and to then serve the content from the original pre-redirect location. Without understanding why you'd want to double the load time for the page (because of the external redirect required to change the browser address bar), and whether this is to be a permanent or temporary redirect for all or just some visitors, it's hard to recommend anything. A bit of background information on the goal would be quite helpful.

For URL rewriting info see the following threads in the Apache forum library:

[webmasterworld.com...]
[webmasterworld.com...]

One note: It requires a 'trick' to prevent this kind of paired redirect/rewrite from looping in a .htaccess context. You must examine the server variable %{THE_REQUEST} with a RewriteCond before doing the external redirect. Otherwise, the two rules will redirect/rewrite back and forth between the two URLs until the client or server reaches its maximum redirection limit and throws an error.

Jim