简体   繁体   中英

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.

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>

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