Forum Moderators: phranque

Message Too Old, No Replies

A little mod rewite help

         

daggaz

4:05 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Hi,

I am very new to the whole mod_rewrite thing, and I may be labouring under a certain misconceptions about what you can and can't do, but what I want to do is to rewrite all urls like this:
[domain.com...] to
[domain.com...]

This I have acheived using the following .htaccess file:
RewriteEngine On
RewriteRule ^property_for_sale/([^/]+)/?$ /tesp.php?1=$1 [L]
RewriteRule ^property_for_sale/([^/]+)/([^/]+)/?$ /tesp.php?1=$1&2=$2 [L]
RewriteRule ^property_for_sale/([^/]+)/([^/]+)/([^/]+)/?$ /tesp.php?1=$1&2=$2&3=$3 [L]

The problem is that apache is not doing this internally but is using an HTTP 301 Moved Permanently response to redirect the browser to the new URL. This changes the URL displayed in the browser to the new URL where as I would like that the original URL is kept and it looks like pages are being served from there and not the php script.

Any help would be greatly appreciated,
Jamie

jdMorgan

4:57 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your code is correct and should do what you want. So that means that there is very likely another RewriteRule, Redirect, RedirectMatch, or RedirectPermanent directive somewhere in the path to /test.php that is invoking external redirects on the test.php requests and exposing your rewritten URLs.

Jim

daggaz

4:59 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Thanks Jim,

I already worked it out, if you look closely I had tesp.php instead of test.php so my server was automatically correcting the spelling mistake with a redirect. Whoops!

Jamie

jdMorgan

5:16 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hah! Well don't feel bad, 'cause I didn't see that either... Time to increase my font size...Again! :(

Jim