用seo的网址中的破折号替换%20,显示错误“找不到对象”

时间:2018-10-08 07:24:35

标签: .htaccess

这是我的.htaccess代码,在其中我将%20替换为破折号(-)时遇到了一些问题。当我删除代码行" RewriteRule ^(.*)$ category.php?edit=$1 [L] "时,URL破折号出现,但页面显示错误“找不到对象!” ,并且当代码行" RewriteRule ^(.*)$ category.php?edit=$1 [L] "可用时,然后显示页面,但网址显示为%20。我想解决这个问题。

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ category.php?edit=$1 [L]

RewriteRule "^(\S*)\s+(\S*)$" /$1-$2 [L,NE,R=302]
RewriteRule "^(\S*)\s+(\S*\s+.*)$" $1-$2 [L]

有人可以帮助我解决吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

.htaccess文件中写入这些规则,以将%20替换为dash(-)

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ category.php?edit=$1 [L]

RewriteRule "^(\S*)\s+(\S*)$" /$1-$2 [L,NE,R=302]
RewriteRule "^(\S*)\s+(\S*\s+.*)$" $1-$2 [L]
RewriteRule ^(.*)-{2,}(.*)$ /$1-$2 [L,R=302]