RewriteRule changes address in user address bar

Oh, the strange things mod_rewrite does!

Postby richardk » Wed Dec 12, 2007 1:08 pm

user types: domain1.com
user gets: domain1.com/main/home.do?d=uk
but user sees: domain1.com

That's nothing like the mod_rewrite you posted. For the above you would use
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^/$ /main/home.do?d=uk [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sam9 » Thu Dec 13, 2007 2:07 am

Richard,

Thanks for your reply. I had tried the same rule you posted and that did not work.

This is what I get in the log:

Code: Select all
127.0.0.1 - - [13/Dec/2007:10:01:09 +0000] [dev/sid#6fa638][rid#9822b8/initial] (2) prefixed with document_root to C:/apache/htdocs/main/home.do
127.0.0.1 - - [13/Dec/2007:10:01:09 +0000] [dev/sid#6fa638][rid#9822b8/initial] (1) go-ahead with C:/apache/htdocs/main/home.do [OK]


when I go directly to http://localhost/main/home.do?d=uk

that works!

I changed the rule to:

Code: Select all
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(localhost)$ [NC]
RewriteRule ^/$ /main/home.do?d=uk [QSA,L]
sam9
 
Posts: 7
Joined: Thu Oct 25, 2007 12:53 am

Postby richardk » Thu Dec 13, 2007 3:08 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ /main/home.do?d=uk [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 5 guests

cron