0

我希望我的 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]
4

1 回答 1

2

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

 `^([^-]*)-([^-]*)\.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

于 2013-10-25T12:21:08.730 回答