I’m building a php framework that redirects all traffic to ROOT/public/index.php and then puts the url in a get request. My problem is that my RewriteConds aren’t working and are accepting files and foldernames.
in root directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
<files .htaccess>
order allow,deny
deny from all
</files>
in public directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
The
[L]flag tells Apache to stop the redirection after the rule was matched. So assuming your ROOT folder comes first, it will run and stop at the redirection, which would render the second redirect useless.To fix the problem have this: