【发布时间】:2017-07-26 14:18:54
【问题描述】:
我在 php 中遇到了一些重定向问题,我为此使用了 .htaccess 但没有成功 我所拥有的是以下 2 个网址:
http://localhost/PROJECT_NAME/USERNAME/348
http://localhost/PROJECT_NAME/USERNAME
我想要的是:
1) 如果请求来自
http://localhost/PROJECT_NAME/USERNAME/111
那么它应该去:
http://localhost/PROJECT_NAME/index.php
2) 如果请求来自
http://localhost/PROJECT_NAME/USERNAME
那么它应该去:
http://localhost/PROJECT_NAME/detail.php
我尝试了什么:
RewriteRule /(\w+)$ detail.php?id=$1 [L]
RewriteRule /(\w+)$ index.php [L]
RewriteRule /$ detail.php?id=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
在此之后没有成功,它适用于索引但不适用于详细信息页面,请帮助大家提前感谢您的时间
兰德尔
【问题讨论】:
标签: php apache .htaccess mod-rewrite url-rewriting