htaccess RewriteRule without RewriteCond not working
.htaccess, apache, fastcgi, mod-rewrite
Solution
It is giving you internal server error (500) because without `RewriteCond` your loop is infinitely looping.
You can use this rule to prevent this:
Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^((?!app\.fcgi/).*)$ /app.fcgi/$1 [L,NC]
`(?!app\.fcgi/)` is a negative lookahead that prevents this rewrite rule to execute if request is already `/app.fcgi/`.
Problem
Why does this work: ``` Options +ExecCGI AddHandler fcgid-script .fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /app.fcgi/$1 [L] ``` But if I remote the `RewriteCond` it doesnt work and I get an internal server error. ``` Options +ExecCGI AddHandler fcgid-script .fcgi RewriteEngine On RewriteRule ^(.*)$ /app.fcgi/$1 [L] ``` If I modify the `RewriteCond` e.g. like this it doesnt work too. ``` RewriteCond %{REQUEST_FILENAME} !-l ``` I want to redirect all requests to app.fcgi. I dont want the user to be able to access files directly. Thanks in advance!