【发布时间】:2014-03-03 12:41:50
【问题描述】:
我想让 RewriteRule 匹配我网站的“基本”url/路径。
我的基本 URL,一旦在 prod 中,将类似于 http://www.site.com,但目前在 dev 中是 http://localhost/dev/site/。 .htaccess 文件位于“站点”文件夹中。
在以下示例中,第一个 RewriteRule 是问题,我无法让它工作。第二个和第三个 RewriteRules 工作正常。如果我到达基本路径/URL,我需要将它带到 index.php?l=default&rte=index。
谢谢。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/$ index.php?l=default&rte=index [NC,L]
RewriteRule ^([a-zA-Z]{2})/$ index.php?l=$1&rte=index [NC,L]
RewriteRule ^([a-zA-Z]{2})/([a-zA-Z-]+)$ index.php?l=$1&rte=$2 [NC,L,QSA]
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite