0

When I write in .htaccess this mod_rewrite

 RewriteEngine on
 RewriteRule ^(.*)\.my_extension$ $1.php

and open url: site.com/index.my_extension this wroks fine, opened index.php

But when I am trying mod_rewrite like this:

 RewriteEngine on
 RewriteRule ^(.*)$ index.php?url=$1

this gives me Internal Server Error.

Why this happened? what is reason?

MadHatter
  • 78,442
  • 20
  • 178
  • 229
Oto Shavadze
  • 113
  • 4
  • You need to add more information. Have you enabled rewrite logging? Are the two rewrite rules in the same config file? It can be possible that you could have a redirect/rewrite loop, as you are catching all then redirecting to index.php?url=foo/bar/index.php?url=foo/bar/index.php, etc. – Danie Apr 25 '13 at 10:53
  • 1) `Have you enabled rewrite logging?` --- if rewrite logging not enabled, then how firts rewriterule works? 2) `Are the two rewrite rules in the same config file?` --- no, just one RewriteRule is in `.htaccess` file. 3) `It can be possible that you could have a redirect/rewrite loop` --- In other servers, catching all then redirecting to index.php works, and here why must happened redirect/rewrite loop? reason of this may be some option? – Oto Shavadze Apr 25 '13 at 11:13
  • read this: http://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-as – HVNSweeting Apr 25 '13 at 11:19

1 Answers1

1
RewriteEngine on
RewriteCond %{REQUEST_URI} !(index.php)
RewriteRule ^(.*)$ index.php?url=$1

You have a redirect loop, you need to exclude index.php from the rules.

David Houde
  • 3,160
  • 1
  • 15
  • 19