【发布时间】:2018-05-07 12:58:30
【问题描述】:
这是我的代码:
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?category=$1 [NC,L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+) index.php?category=$1&subcategory=$2 [NC,L]
现在的问题是,它实际上将目录和子目录分别视为类别和子类别。我尝试了许多不同的解决方案来保持目录不变,但似乎都没有。
有人建议我:
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
与
RewriteCond %{REQUEST_URI} !^/css
RewriteCond %{REQUEST_URI} !^/js
RewriteCond %{REQUEST_URI} !^/images
RewriteCond %{REQUEST_URI} !^/digitalserp
RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]
直到现在都没有工作。请建议我在不重写所有 CSS、JS 和图像的情况下制作干净的 URL(如 http://www.example.com/category/sub-category)的最佳方法。
谢谢
【问题讨论】:
标签: apache .htaccess mod-rewrite url-rewriting