Mobile app version of vmapp.org
Login or Join
Fox8124981

: Apache rewrite returns error 500 I'm trying to figure out what I'm doing wrong with this .htaccess rewrite: Options -Indexes RewriteEngine on RewriteBase /test/site/ RewriteOptions MaxRedirects=10

@Fox8124981

Posted in: #403Forbidden #Apache #Htaccess #HttpCode500 #ModRewrite

I'm trying to figure out what I'm doing wrong with this .htaccess rewrite:

Options -Indexes

RewriteEngine on
RewriteBase /test/site/
RewriteOptions MaxRedirects=10

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test/site/public/page.php?rel= [NC,L,B]


I have an Front end script that handles all of the requests. In my case I don't need or have index.php/index.html file in my root project (/test/site/). That causes Apache to throw 403 error because of the first line of the code.

The code will work only if you access the links as follows:
localhost/test/site/public/index http://localhost/test/site/public/something/else/index.html


But if you enter
localhost/test/site/public/

It'll throw 403 error.

I'm pretty sure I'm doing something wrong but I can't figure it out.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Fox8124981

1 Comments

Sorted by latest first Latest Oldest Best

 

@Frith620

Well, your RewriteRule does not apply because that path you are trying is a directory. As set up, your .htaccess redirects things that are neither.

You will need an additional rule or a custom 403 page to handle directories. You may also change your condition to files only. In other words, remove the second RewriteCond line. Which you do depends on what you want to happen for a directory path.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme