Forum Moderators: phranque

Message Too Old, No Replies

Why is rewritten URL shown in browser

         

celtdkey

3:11 pm on Nov 28, 2009 (gmt 0)

10+ Year Member



I'm using the following rule

RewriteRule ^[D-Dd-d][E-Ee-e]/([0-9][0-9][0-9])(.*)$ http://www.example.com/Star/Properties/PropertyDetails_DE.php?Ref=$1 [L]

to rewrite a nice looking permalink to the actual url. For some reason, the rewritten url shows up in the browser's address bar, instead of leaving the permalink there. I dont't understand why. Of course this leads to problems with Google, because all links in my sitemap are of the short type, while Google actually only finds the original long url's. Does anybody know how I can prevent the rewritten url from being shown?

[edited by: jdMorgan at 3:41 pm (utc) on Nov. 28, 2009]
[edit reason] example.com [/edit]

jdMorgan

3:41 pm on Nov 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code invokes a 302 redirect, not a rewrite, because it includes the protocol and hostname in the substitution path, making that path a URL, not an internal server filepath.

Remove "http://www.example.com/" from the substitution path, leaving it as a local filepath.

[added]
Also, your pattern could use a tweak: Replace

 ^[D-Dd-d][E-Ee-e]/([0-9][0-9][0-9])(.*)$ 

with
 ^de/([0-9][0-9][0-9])(.*)$ 

and then use the [NC] flag on your rule, making the comparison case-insensitive.

Should you decide not to use this speed-up, then the correct pattern that you likely intended is

 ^[Dd][Ee]/([0-9][0-9][0-9])(.*)$ 

[/added]

Jim

celtdkey

4:16 pm on Nov 28, 2009 (gmt 0)

10+ Year Member



Wow, thank you soo very much. I have been trying to solve this for weeks now and it was driving me crazy. It works perfectly now. Thanks again Jim.