Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect based on query string

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
I am trying to redirect a page in our eCommerce website but have been unsuccessful thus far in doing so. We need:


to point to:


Any suggestions? I've tried the following in my .htaccess file but it doesn't work properly:

Code:
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{query_STRING} cPath=3_28
RewriteRule ^index\.php$ [URL unfurl="true"]http://www.mcgillinc.com/shop/creative/solutions[/URL] [R=301,L]
 
Hi

Would be better to write it in all uppercases, as [tt]%{QUERY_STRING}[/tt], but your example works fine for me.

Give us more details about that "doesn't work properly". And ask mod_rewrite to log its activity.

Feherke.
 
I'm afraid this is a rather foreign topic to me. I tried to add a line to my .htaccess file to log mod_rewrite activities to /var/log/rewrite.log:

Code:
Options +FollowSymLinks
RewriteEngine on

RewriteLog "/var/log/rewrite.log"

RewriteCond %{QUERY_STRING} cPath=3_28
RewriteRule ^index.php$ [URL unfurl="true"]http://www.mydomain.com/shop/creative/solutions[/URL] [R=301,L]

When I placed this on the server, I got an Internal Server Error across the entire website. So I've been unable to log mod_rewrite's activities, but basically what is happening is when I visit it is not redirecting anywhere. If someone can help shed some light on this, it would help greatly.
 
Hi

You can not put [tt]RewriteLog[/tt] directive into a local configuration file. Put it in httpd.conf.

And try the expression less restrictive. For example
Code:
RewriteCond %{QUERY_STRING} [red].*[/red]cPath=3_28[red].*[/red]
RewriteRule index.php [URL unfurl="true"]http://www.mydomain.com/shop/creative/solutions[/URL] [R=301,L]
( Note, that I removed the caret ( ^ ) and dolar ( $ ) signs. )

Feherke.
 
I got this to work, by moving the .htaccess out of the site root and into the /shop directory. Not sure why, but that worked... thanks for your help. Any idea why it didn't work in the site root?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top