Apache htaccess正在将%20替换为-

Apache htaccess正在将%20替换为-,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,请对我放轻松,但我对htaccess重写和其他方面还是新手,以前从未做过 我正在尝试用URL中的-替换%20。我似乎不明白 你能告诉我下面的htaccess代码有什么问题吗?仅在URL重写部分 # Begin hotlink protection # RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://webawwards.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.webaw

请对我放轻松,但我对htaccess重写和其他方面还是新手,以前从未做过

我正在尝试用URL中的-替换%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>
#开始热链接保护#
重新启动发动机
重写cond%{HTTP_REFERER}^http://webawwards.com/.*$[NC]
重写cond%{HTTP_REFERER}^http://www.webawwards.com/.*$[NC]
重写cond%{HTTP_REFERER}^http://webawwardscom.ipage.com/.*$[NC]
重写cond%{HTTP_REFERER}^http://www.webawwardscom.ipage.com/.*$[NC]
重写规则(gif | jpg | png)$-[F]
#终端热链接保护#
#开始缓存控制#
过期于
ExpiresDefault“现在加上240分钟”
ExpiresByType text/html“现在加240分钟”
FileTag MTime大小
ExpiresDefault“现在加上240分钟”
#端缓存控制#
#Url重写开始#
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写规则^([^\.]+)$$1.php[NC,L]
重写cond%{HTTP_HOST}^webawwards\.com[NC]
重写规则(.*)http://www.webawwards.com/$1[L,R=301]
#从开始或之后删除空格/
重写规则^(.*/|)[\s%20]+(.+)$$1$2[L]
#从末尾或前面删除空格/
重写规则^(.+?)[\s%20]+(/.*)$$1$2[L]
#将空格替换为中间的
重写规则^([^\s%20]*)(?:\s|%20)+(.*)$$1-$2[L,R]
#Url重写结束#
#启用gzip压缩
mod_gzip_on Yes
是的
mod_gzip_item_include file\(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*
它似乎不起作用

我希望将www.domain.com/blog/post.php?title=text%headline替换为www.domain.com/blog/title-headline

我知道上面的代码是错误的,但我想不出在哪里,试试这个

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /blog/post\.php\?title=(.*)%20(.*)\ HTTP
RewriteRule ^ /blog/%2-%3? [R=301,L]

因此,如果
标题
包含空格,它将被重写为
-

我已经尝试过的可能的副本。不适合我。“文本%headline”-可能是“文本%20headline”?