1
請對我輕鬆一下,但我仍然是新的htaccess重寫和所有,之前從未做過。htaccess將%20替換爲 -
我試圖用我的網址替換%20。我似乎無法弄清楚。
你能告訴我在接下來的htaccess代碼中出了什麼問題嗎?只有在URL重寫部分
# Begin hotlink protection #
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://webawwards.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.webawwards.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://webawwardscom.ipage.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.webawwardscom.ipage.com/.*$ [NC]
RewriteRule .(gif|jpg|png)$ - [F]
# End hotlink protection #
# Begin cache control #
ExpiresActive on
ExpiresDefault "now plus 240 minutes"
ExpiresByType text/html "now plus 240 minutes"
<FilesMatch "\.(css|png|bmp|ico|htm|gff|html|js|jpg|jpeg|gif|gcf)$">
FileETag MTime Size
ExpiresDefault "now plus 240 minutes"
</FilesMatch>
# End cache control #
# Url rewritting start #
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} ^webawwards\.com [NC]
RewriteRule (.*) http://www.webawwards.com/$1 [L,R=301]
# 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]
# Url rewrite end #
# Enable gzip compression
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
它似乎沒有工作。
我想www.domain.com/blog/post.php?title=text%headline由www.domain.com/blog/title-headline
代替我知道上面的代碼是錯誤的,但我不能找出其中
可能重複重定向所有網址使用%20到 - ](http://stackoverflow.com/questions/19797848/htaccess-redirect-all-urls-using-20-to) –
我已經嘗試過了。沒有爲我工作。 – TonyS
「text%headline」 - 也許是「text%20headline」? – user4035