Hell guys, can someone help me with a .htaccess rule to redirect such url type:
old url: video/displayresults/?pattern=searchedword
new url: video/search/?searchword=searchedword
So i want to redirect any old url to the new url
Thanks
启用mod_rewrite
并.htaccess
通过httpd.conf
(如果尚未启用),然后将此代码放入您的DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^pattern=(.*)$ [NC]
RewriteRule ^(video)/displayresults/?$ /$1/search/?searchword=%1 [L,NC,R=301]
您想查找 htaccessRewriteRule
指令。您需要构建它捕获的正则表达式“/displayresults/?” 并将其解析为“/search/”。确保您启用了 mod_rewrite
例子:
RewriteRule ^(. )/displayresults/(.)$ 1/search/$2
这假定 displayresults 是一个文件夹名称。