简体   繁体   中英

Can't use ? when redirect 301 with .htaccess

I have a website which is being renewed.

It has url's like site.com/page.php?p=company&l=nl The new URL is site.com/company

I would like to use .htaccess to redirect 301. ( I would like to keep the SEO pagerank for the old pages )

Because of the ? it doesn't work.

This is the rule I use in my htaccess which doesn't work:

Redirect 301 /page.php?p=company&l=nl http ://www.site.com/company

This is the rule I use in my htaccess which does work:

Redirect 301 /page.php http ://www.site.com/company

I need the ?p=...

This should work:

RewriteCond %{QUERY_STRING}  ^p=company&l=nl$ [NC]
RewriteRule ^page\.php$ http ://www.site.com/company? [R=301,NE,NC,L]

Remove the space between http and :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM