【发布时间】:2016-02-25 17:13:45
【问题描述】:
我正在使用 htaccess 文件中的 mod_rewrite 将一些 url 重定向到特定页面。该项目是在核心 PHP(无框架)中开发的,我正在使用 xampp 服务器,
例如:我希望将以下 url 重定向到 test.php
localhost/project/any_string //should be redirected to test.php
localhost/project/any_string/test //should be redirected to new_test.php
和
localhost/project/any_string.php //should be redirected to any_string.php only
localhost/project/any_string/any_string.php //should be redirected to any_string/any_string.php only
我启用了 mod_rewrite,任何帮助将不胜感激。
【问题讨论】:
-
'RewriteRule ^([a-z0-9_\-]+) test.php [L,NC]'
标签: php apache .htaccess redirect mod-rewrite