简体   繁体   中英

mod_rewrite infinite loop with SEO friendly URLs

I'm tidying up my urls to make them SEO friendly, but I have run into the issue of getting into an infinite loop and although I have read various other articles, I can't seem to find an answer to my question.

Example:

  • Current URL : www.example.co.uk/aboutus.php
  • Required SEO friendly URL: www.example.co.uk/about-us

Note: Since the URLS are slightly different I can't just drop off the .php

I can get the /about-us link to correctly rewrite to show the /about.php content using:

RewriteRule ^about-us /aboutus.php [NC,L]

But, what I also need to achieve is that the old url which is indexed in Google is redirected to the new url to preserve page rank:

RewriteRule ^aboutus.php /about-us [NC,L,R=301]

But these two rules get stuck in a loop, how can I resolve this please?

Thanks

need to check an incoming request

RewriteCond %{THE_REQUEST} \s\/aboutus\.php\s
RewriteRule . /about-us [NC,L,R=301]

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