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

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.

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]

Fixed, I added this:

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.