【发布时间】:2013-05-31 12:01:20
【问题描述】:
我在我的网页上处理 URL,但我无法解决具有 2 个参数的 URL 的问题。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-z\-]+)/?$ index.php?strona=$1 [L]
RewriteRule ^([a-zA-Z0-9-z\-]+)/([a-zA-Z0-9-z\-]+)/?$ index.php?strona=$1&id=$2 [L]
URL 看起来不错,只是当我当前的 URL 有 2 个参数时(例如,我在 http://example.com/subpage/5 上,整个网页都损坏了(样式表、导航等)因为 .htaccess 将所有链接更改为:
(for example navigation):
http://example.com/subpage_with_2_parameters/home
instead of
http://example.com/home
只有一个参数的页面(例如:http://example.com/contact)工作正常。
我想到的唯一解决方案(这很可怕)是绝对链接。
【问题讨论】:
标签: regex apache .htaccess mod-rewrite