【发布时间】:2012-03-04 23:38:00
【问题描述】:
我有以下目录设置:
http://www.mysite.com/public/
我正在使用以下重写从可见 URL 中删除“公共”文件夹:
#rewrite the URL to display the subdirectory as the main directory for all links
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
RewriteCond %{REQUEST_URI} !^/public
Rewriterule ^(.*)$ /public/$1 [L]
这很好用,并且可以正确重定向所有内容。但是,我也想重写一些位于“public”子文件夹中的动态页面,但是我发现任何重写都无法与上述规则结合使用。
例如,使用上面的子目录重写规则,转到如下 URL:
http://www.mysite.com/item.php?id=1&name=item_name
...应该改写为:
http://www.mysite.com/items/item_name
想法?
【问题讨论】:
标签: php regex .htaccess mod-rewrite friendly-url