简体   繁体   中英

Rewrite rule does not work

I want my URL to be like http://www.domainname.com/Seagate-abc-Buyout-22.html but my rewrite rules do not apply. Do you spot anything wrong?

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]

Doesn't work because your regex is incorrect:

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

Try changing your rule to:

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

This will internally rewrite above URL to /index.php?title=Seagate&sid=abc-Buyout-22

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM