mod-rewrite recursive loop

后端 未结 6 921
死守一世寂寞
死守一世寂寞 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:16

    If you're only concerned about search engines, you could create a robots.txt file containing:

    User-agent: *
    Disallow: /news.php
    

    This will make sure that search engines don't follow the news.php links.

    To fix your rewrite rules, you might try adding L to the first RewriteRule to make sure that mod_rewrite doesn't continue:

    RewriteRule ^news/([0-9]+) /news.php?id=$1 [PT,L]
    RewriteCond %{QUERY_STRING} ^id=([0-9]+) 
    RewriteRule ^news\.php /news/%1? [R=301,L]
    

提交回复
热议问题