i'm trying to rewrite my urls in the form of
localhost/myapp/view/something or
localhost/myapp/crud/something
to
localhost/myapp/view.pl?view=something or
localhost/myapp/crud.pl?action=something
all other request should be mapped like this: localhost/myapp/login to localhost/myapp/login.pl
I tried it with this .htaccess file but i get a recursion if i enable the last RewriteRule, i don't get why because i protected it with a RewriteCond. This is my first .htacces mod_rewrite file so please be patient with me ;)
RewriteEngine On
RewriteRule ^/?crud/([^/]*)$ /myapp/crud.pl?action=$2 [QSA]
RewriteRule ^/?view/([^/]*)$ /myapp/view.pl?view=$2 [QSA]
RewriteCond $1 !^/(view|crud)$
RewriteRule ^/?([^/]*)$ /myapp/$1.pl [QSA]
Update:
I removed the leading / and added [L] flags now i get the following error in apache's error.log:
[Mon Jul 09 11:55:33 2012] [error] [client 127.0.0.1] File does not exist: /srv/http/myapp/myapp
New File:
RewriteRule ^crud/([^/]*)$ myapp/crud.pl?action=$2 [L,QSA]
RewriteRule ^view/([^/]*)$ myapp/view.pl?action=$2 [L,QSA]
RewriteCond $1 !^(view|crud)$
RewriteRule ^([^/]*)$ myapp/$1.pl [QSA]