我在网站上设置了以下重写规则。我正在尝试设置它,所以我有以下不同的 URL。
当前 .htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^([^-]*)/$ ?action=$1 [L]
RewriteRule ^([^-]*)-([^-]*)/$ ?action=$1&id=$2 [L]
必需的网址
www.site.com
www.site.com/page/
www.site.com/product-1234/
www.site.com/privacy-policy/
问题是第二个重写规则正在影响privacy-polcy
url,但它不应该,因为第二个重写规则仅特定于包含产品 ID 的产品页面。
我还试图忽略作为我网站结构存在的目录,因此在 root 下我有以下目录,我不希望重写规则影响这些目录,因为用户不应该对这些目录一无所知。
/system/
/tasks/
# catch more specific urls:
RewriteRule ^product-([0-9]*)/$ ?action=product&id=$1 [L]
# ignore requests that want files or directories that do exist:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# then continue with the less specific:
RewriteRule ^([^/]*)/$ ?action=$1 [L]