0

I've searched a lot, but couldn't find a solution. I'm trying to redirect php based urls with parameters to SEO friendly urls.

For example I want to redirect static.php?content_id=27 to /presentation/, but I get infinite loop error.

Here is my code:

RewriteEngine On
RewriteBase /

RewriteRule ^presentation/$ static.php?content_id=27
RewriteCond %{QUERY_STRING} content_id=27
RewriteRule ^static\.php$ /presentation/? [L,R=301]

The old urls are indexed by google so I need this redirect.

Thanks

webtech
  • 311
  • 3
  • 13

1 Answers1

1

Try this :

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /static\.php\?content_id=27 [NC] 
RewriteRule ^ /presentation/? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /static.php?content_id=27 [NC,QSA,L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Oh great, thank you very much. Why do I need %{REQUEST_FILENAME} !-f, and %{REQUEST_FILENAME} !-d. Thanks : – webtech Aug 02 '15 at 17:00
  • Mm not working, because if I add the same script for static.php?content_id=14 for example, it still gets content from static.php?content_id=27 – webtech Aug 02 '15 at 17:11
  • You didn't understand my question at all :) – webtech Aug 02 '15 at 20:30