user2731816
user2731816

Reputation: 36

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]

Upvotes: 0

Views: 177

Answers (1)

anubhava
anubhava

Reputation: 784898

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

Upvotes: 2

Related Questions