简体   繁体   English

301使用.htaccess重定向动态URL

[英]301 Redirect Dynamic URL with .htaccess

I have dynamic URL that I want to redirect (301) with .htaccess. 我有要使用.htaccess重定向(301)的动态URL。

Old URL: mysite.com/index.php?route=product/search& keyword = searchphrase 旧网址:mysite.com/index.php? route = product/search& 关键字 = 搜索词组

New URL: mysite.com/index.php?route=product/search& search = searchphrase 新网址:mysite.com/index.php? route = product/ search& search = searchphrase

I need that the redirect will change the URL from search& keyword to search& search , but will keep the searchphrase . 我需要重定向将URL从search& 关键字更改为search& search ,但将保留searchphrase

How to do this? 这个怎么做? Thanks! 谢谢!

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file: 通过httpd.conf启用mod_rewrite.htaccess ,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(index\.php\?route=product/search)&keyword=([^\s&]+) [NC]
RewriteRule ^ /%1&search=%2 [R=301,L,NE]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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