我希望我的网址与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]
答案 0 :(得分:2)
因为你的正则表达式不正确而无效:
`^([^-]*)-([^-]*)\.html$` cannot match `Seagate-abc-Buyout-22.html`
尝试将规则更改为:
RewriteRule ^([^-]*)-([^.]*)\.html$ /final.php?title=$1&sid=$2 [L,QSA,NC]
这将在内部将上述网址重写为/index.php?title=Seagate&sid=abc-Buyout-22