你好在我的項目中我有以下htaccess。 一切工作正常,例如我輸入以下網址domain.com/ test some test / test /
htaccess在刪除空格上的奇怪行爲
成爲 domain.com/test+some+test/test
預期
我奇怪的,至少是當我編輯domain.com/test+some+test/test
到
domain.com/test+some+test /test
和回車鍵再次結果如下:
domain.com/test+some+test%20%20%20%20%20/test
不應該再次逃脫嗎?如果我錯過了一些東西,請指出。
Options All -Indexes +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
# Turn mod_rewrite on
RewriteEngine On
RewriteBase/
# remove spaces from start or after/
RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
# remove spaces from end or before/
RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L]
# replace spaces by + in between
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1+$2 [L,R=301]
# Remove trailing slash
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [L,R=301]
# Add trailing slash
#RewriteCond %{REQUEST_URI} !(/$|\.)
#RewriteRule (.*) %{REQUEST_URI}/ [L,R=301]
# Remove multiple slashes
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/{2,} [NC]
RewriteRule ^(.*) $1 [R=301,L]
# Clean url rewrite
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*\.(png|jpg|jpeg|bmp|gif|css|js|json)$ [NC]
RewriteRule ^(.*)$ /index.php?req=$1 [L,QSA]
</IfModule>
UPDATE
經過進一步調查,並在第2周的RewriteRules應用R開關的建議通過Anubhava只有1個問題仍然
,如果我進入http://tms.localhost/test+some+test /test
成爲http://tms.localhost/test+some+test%20%20%20/test
但如果我進入它像這樣http://tms.localhost/test some test /test
它變得如預期http://tms.localhost/test+some+test/test
Omg you again:P this failed Anubhava domain.com/你好+有+男童%20%20%20 /測試。測試:domain.com/hello+there+boy/test(3spaces,如你所見) – Syd
在你的瀏覽器中輸入'http://domain.com/test+some+test/test'吧? – anubhava
是的,在測試之前有3個空格,測試 – Syd