【发布时间】:2015-03-19 12:05:36
【问题描述】:
尝试制定一组 .htaccess mod_rewrite 规则来设置这些链接:
domain.com/content-page
domain.com/region/another-page
domain.com/region/brand/more-content-here
获取文件:
domain.com/content-page.php
domain.com/region-another-page.php
domain.com/region-brand-more-content-here.php
其中“地区”和“品牌”以及页面名称都是可变/可更改的。
到目前为止我有:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,C]
RewriteRule ([^/]+)/([^/]+) $1-$2 [NC,L]
这有效,但仅适用于一个正斜杠。如上所述,域之后的 URL 可能没有、一或两个正斜杠。尝试扩展它以处理多个(或不)斜杠没有任何运气。
【问题讨论】:
标签: php apache .htaccess mod-rewrite