友好的URL并删除php前缀

时间:2012-06-25 08:26:29

标签: .htaccess mod-rewrite url-rewriting

我在我的htaccess中有这个

Options +MultiViews 

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ dash.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ dash.php?p=$1

我试图制作这个网址:

http://mywebdomain.com/dash.php?p=dash&mode=All

看起来像这样:

http://mywebdomain.com/dash/All

有办法做到这一点吗?

如果我有这样的话:

http://mywebdomain.com/user/manage.php?p=manage&mode=Me

我怎么能看到这样:

http://mywebdomain.com/user/manage/Me

我已成功设法通过选项+多视图命令删除了.php扩展程序,但我正在努力解决为什么它不会重写以扩展部分的扩展部分网址。

感谢您提前提供任何帮助:) 强尼

1 个答案:

答案 0 :(得分:0)

启用MultiViews后,您无需Rewrite即可完成此操作。

由于文档根目录中存在dash.php文件,Apache会将请求传递给/dash/anythingdash.php,并且该php脚本可以解析URI(在$_SERVER["REQUEST_URI"]中找到)检查完整的uri叫什么。

{p>同样适用于/user/manage.php ...

相关问题