0

I'm trying to rewrite

http://localhost/messages/index.php?s=compose

to

http://localhost/messages/compose

but it gives me Internal Server Error

RewriteEngine On
RewriteRule ^messages/([^/]*)$ /messages/index.php?s=$1 [L]

I'm using a online site where you can generate rules so it should work, on the site I can make a rule to rewrite it to http://localhost/compose.html that works and gives me no error, but rewriting for http://localhost/messages/compose give me error.

Mod rewrite engine is on

Is it something to do with fact that messages is a folder/directory?

Jorm
  • 609
  • 2
  • 6
  • 11
  • Look in the Apache error log for more details on what the error was. But most likely it is a redirect loop wherein `index.php` matches the same rule again and rewrites itself. Add `RewriteCond %{REQUEST_FILENAME} !-f` before `RewriteRule`. – Michael Berkowski Dec 10 '15 at 19:34
  • You were right, that RewriteCond fixed it. thank you – Jorm Dec 10 '15 at 19:36
  • Possible duplicate of [mod\_rewrite loops even with L flag](http://stackoverflow.com/questions/2127131/mod-rewrite-loops-even-with-l-flag) – Michael Berkowski Dec 10 '15 at 19:46

1 Answers1

0

Exclude the dot in pattern.

RewriteEngine On
RewriteRule ^messages/([^/.]*)$ /messages/index.php?s=$1 [L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115