【发布时间】:2016-02-26 17:01:33
【问题描述】:
我正在使用 htaccess 获取干净的 url。只要参数不带有空格,它就可以正常工作。在这种情况下,它会转换 %20 中的空间,我收到 404 错误。
所以基本上是 URL:http://localhost:8080/series/dynamics/admin/cleanURL/green%20apple
给我 404 错误。但 URL:http://localhost:8080/series/dynamics/admin/cleanURL/greenapple 工作正常。
还有一种方法可以从 URL 中删除目录详细信息,我试过了
RewriteRule ^series/dynamics/admin/cleanURL/(.*)$ /$1 [L,NC,R]
但是没用
htaccess
<IfModule mod_rewrite.c>
Options +MultiViews
Rewriteengine on
RewriteBase /series/dynamics/admin/cleanURL/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^series/dynamics/admin/cleanURL/(.*)$ /$1 [L,NC,R]
Rewriterule ^([a-zA-Z0-9]+)/?$ index.php?product=$1
RewriteRule ^(.*)(\s|%20)(.*)$ /$3-$4 [R=301,L,NE]
#rewrite group and subgroup e.g. http://.../value1/value2/ [L,NC,QSA]
Rewriterule ^([a-zA-Z0-9]+(.*)+)/([^/]+(.*)+)/?$ index.php?product=$1&subgroup=$2 [L,NC,QSA]
</IfModule>
【问题讨论】:
标签: apache .htaccess clean-urls