mohana rao
mohana rao

Reputation: 429

SEO Friendly URLs Rewrite Using Htaccess And Mod_Rewrite

I have used below RewriteRule in .htacces file then it is working as /page/NDT:REBGEARPOSGM-8630342

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^page/([A-Za-z0-9\-:]+$)$ page.php?partid=$1
</IfModule>

But I want work as /page/NDT:REBGEARPOSGM-8630342.html. For this I have used below RewriteRule and it is giving error 404 .

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^page/([A-Za-z0-9\-:]+$)\.html page.php?partid=$1
</IfModule>

Any one please assist where I did wrong or any other way to do this. Thanks in advance.

Upvotes: 1

Views: 133

Answers (1)

anubhava
anubhava

Reputation: 784878

You have a misplaced $ anchor in your regex. Use this rule:

<IfModule mod_rewrite.c>

    Options -MultiViews    
    RewriteEngine on
    RewriteRule ^page/([a-z0-9:-]+)\.html$ page.php?partid=$1 [L,QSA,NC]

</IfModule>

Upvotes: 1

Related Questions