Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 在htaccess中将旧url重定向到新url?_.htaccess - Fatal编程技术网

.htaccess 在htaccess中将旧url重定向到新url?

.htaccess 在htaccess中将旧url重定向到新url?,.htaccess,.htaccess,我的网站有旧的网址,它不利于搜索引擎优化,所以我需要重定向我所有的旧网址到新的网址。但它不起作用。谁能帮我或给我解决方案。谢谢 orl url: /country?cn=United%20Arab%20Emirates&s-country=312 /country?cn=Dominican%20Republic&s-country=534 /country?cn=United%20Kingdom&s-country=268 新网址: /country/united-ar

我的网站有旧的网址,它不利于搜索引擎优化,所以我需要重定向我所有的旧网址到新的网址。但它不起作用。谁能帮我或给我解决方案。谢谢

orl url:

/country?cn=United%20Arab%20Emirates&s-country=312
/country?cn=Dominican%20Republic&s-country=534
/country?cn=United%20Kingdom&s-country=268
新网址:

/country/united-arab-emirates-city-tours
/country/dominican-republic-city-tours
/country/united-kingdom-city-tours
我的访问权限:

RewriteRule ^country?cn=([a-zA-Z_-]+)&s-country=([0-9]+)$           index.php?cmd=country&countryname=$1 [L,NC,QSA]
RewriteRule ^country/([a-zA-Z0-9_-]+)-city-tours$           index.php?cmd=country&countryname=$1 [L,NC,QSA]

嗨@Asamoa我在这里分享我的一些经验:

在处理更改url时,我正在使用Wordpress和数据库cpanel。您可以访问cpanel(或phpmyadmin)从后端更改url。它将重定向到新的url

由于我使用的是Wordpress,我安装了Yoast SEO,您可以尝试阅读他们提供的一些有用的博客,请参阅


我希望有帮助

您不能使用RewriteRule匹配查询字符串,它只检查URL的路径组件。要对查询字符串进行任何匹配,您需要一个RewriteCond。而且您真的不需要数字“s-country”属性来处理这些请求吗?由于该参数在“干净URL”示例中不存在,并且http服务器无法以某种方式猜测。。。