redirect 301 to homepage from dinamic page php

New to mod_rewrite? This is a good place to start.

redirect 301 to homepage from dinamic page php

Postby jorkam » Tue Aug 11, 2009 7:18 am

Hi! everyone.

I tried some of the expressions from richard from: viewtopic.php?t=18537&start=10

I'm trying to redirect 301 from the url: index.php?lang=EN&id=12 to the homepage of the site, but with these expression I get these one: http://www.domain.com/?lang=EN&id=12.
All parameters are included before the domain and only disappear index.php.

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^(index\.php)?lang=EN&id=12$ [NC]
RewriteRule ^index\.php$ http://www.domain.com/ [R=301,L]

Any one have a soluction?

Best regards
jorkam
 
Posts: 7
Joined: Wed Jul 30, 2008 7:25 am

Postby richardk » Wed Aug 12, 2009 11:44 am

Adding a ? to the end of the new URL sets an "empty" query string.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?id=12(&.*)?$ [NC]
RewriteCond %{QUERY_STRING} ^(.*&)?lang=EN(&.*)?$ [NC]
RewriteRule ^index\.php$ http://www.example.com/? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jorkam » Thu Aug 13, 2009 1:15 am

Yeah! Thanx again richardk. It's OK
jorkam
 
Posts: 7
Joined: Wed Jul 30, 2008 7:25 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 32 guests

cron