0

Hey,

I have a .htaccess file but I wanted to know if you can make the file check if a directory exists and if it does go to there and ignore the commands...

such as ROOTURL/category/page/ this changed the URL to index.php?cat=$&page=$ but say I put in ROOTURL/dan/ and that directory exists it errors and doesn't go into the directory...

Hope you understand my question?

Dan

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Danny159
0

Hi,

Below is a .htaccess file from WordPress. The third and fourth lines check whether the requested path is an actual file or directory. If either returns true, then the rewrite rule will not be followed.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

R.

0

Hi,

Below is a .htaccess file from WordPress. The third and fourth lines check whether the requested path is an actual file or directory. If either returns true, then the rewrite rule will not be followed.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

R.

Thanks for your comment, this is my .htaccess file now, so I made a direcotry called testing in the root, but it doesnt list the directory contents... just errors so where would I put that code?

RewriteEngine on
RewriteBase /

Options +Indexes
IndexOptions +FancyIndexing

#Rules for root 
RewriteRule ^$ /index.php

#The page url must match the section name
RewriteRule ^([^/.]*)$ $1/ [R]
RewriteRule ^([^/.]*)/$ index.php?secID=$1&pageID=$1 [QSA]

#Rules for /section/page
RewriteRule ^([^/.]*)/([^/.]*)$ $1/$2/ [R]
0

Fixed, I added this:

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.