Htaccess RewriteRule without RewriteCond doesn't work

Why it works:

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.fcgi/$1 [L]

      

But if i delete RewriteCond

it doesn't work and i get internal server error.

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^(.*)$ /app.fcgi/$1 [L]

      

If I change RewriteCond

eg. for example this doesn't work either.

RewriteCond %{REQUEST_FILENAME} !-l

      

I want to redirect all requests to app.fcgi. I don't want the user to be able to access files directly.

Thanks in advance!

+3


source to share


1 answer


It gives you an internal server error (500), because without RewriteCond

your loop endlessly loops.

This rule can be used 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 from being executed if the request is already there /app.fcgi/

.

+3


source







All Articles