重写规则不起作用


Rewrite rule does not work

我希望我的URL像http://www.domainname.com/Seagate-abc-Buyout-22.html但我的重写规则不适用。你发现什么不对劲吗?

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www'.Domainname'.com
RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=permanent,L]
RewriteRule ^([^-]*)-([^-]*)'.html$ /final.php?title=$1&sid=$2 [L]
不起作用

,因为您的正则表达式不正确:

 `^([^-]*)-([^-]*)'.html$` cannot match `Seagate-abc-Buyout-22.html`

尝试将规则更改为:

 RewriteRule ^([^-]*)-([^.]*)'.html$ /final.php?title=$1&sid=$2 [L,QSA,NC]

这将在内部重写上述 URL 以/index.php?title=Seagate&sid=abc-Buyout-22