繁体   English   中英

htaccess将带有扩展名的旧index.php重定向到新的url

[英]htaccess redirect old index.php with extensions to new url

我在通过htaccess正确重定向这些链接时遇到了一些麻烦。

网站使用是动态的,现在是静态的。

该页面不再存在,但是仍然有通过这些url引用该页面的链接,因此我需要将它们重定向。

http://www.example.com/?en=about

http://www.example.com/index.php/?en=about

应将它们重定向到最近创建的新的静态html页面。

通过htacess进行此操作的最佳方法是什么? 我尝试了一些重写,但是没有用。 任何帮助将不胜感激-谢谢

我建议文件名与值en相匹配

 RewriteEngine on

RewriteCond %{QUERY_STRING} ^en=([^&]+)
RewriteRule ^(index.php/|)$ /%1.html? [R,L]

如果只有一页-关于我们,则下面的代码

RewriteEngine on

RewriteCond %{QUERY_STRING} ^en=about
RewriteRule ^(index.php/|)$ /about-us.html? [R,L]

您应该可以301进行永久重定向:

Redirect 301 /old.php /new.php

因此,在您的情况下,您需要以下内容:

Redirect 301 /index.php/?en=about /about.php

暂无
暂无

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

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