Reputation: 1171
I have this piece of code:
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I don't know how to allow only directory with name "public" which is inside folder where is .htaccess, other names than this dir should be transfered to index.php. How could I do that?
Upvotes: 1
Views: 87
Reputation: 51711
Add another RewriteCond
to exclude public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} ^/public(/.*)?$
RewriteRule ^(.*)$ index.php?url=$1 [L]
Now, the redirection would only work for /public
directories only. If you want the url
to just have the rest of the path that's below public like url=subfolder/page.php
for /public/subfolder/page.php
use
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^public/?(.*)$ index.php?url=$1 [L]
Upvotes: 1
Reputation: 784998
Change your code with this:
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (?!^public(/.*|)$)^(.*)$ index.php?url=$1 [L,NC,R=302]
ErrorDocument 404 /index.php
</IfModule>
Upvotes: 0