mod-rewrite recursive loop

后端 未结 6 900
死守一世寂寞
死守一世寂寞 2021-02-11 08:24

I want to change my website\'s dynamic urls to Search Engine Friendly URL\'s

Now the urls like this www.website.com/news.php?id=127591 , I want it became this www.websit

6条回答
  •  迷失自我
    2021-02-11 09:09

    Please try this rule in your .htaccess file:

    RewriteEngine on
    Options +FollowSymlinks -MultiViews
    
    RewriteCond %{THE_REQUEST} \?id=([0-9]+)\s [NC]
    RewriteRule ^news\.php /news/%1? [R=301,L]
    
    RewriteRule ^news/([0-9]+) /news.php?id=$1 [L,NS,NE,QSA,NC]
    

    UPDATE:: Based on your comments:

    Inside news.php when URL doesn't have /some-title then output this META tag to stop indexing /news/987 type URIs:

    
    

    Once you notice URI of /news/987/some-title inside news.php simply mask above META tag. I have tested it and seems to be working fine so let me know if doesn't work for you.

提交回复
热议问题