Connor Gurney
Connor Gurney

Reputation: 690

How to use .htaccess with sub directories of directories

Say I have the following code:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/?$ controller.php?request=$1 [L,QSA]

If I go to a folder such as folder/subfolder/, it gives me a 404 error, although the folder exists.

How can I make this work with subdirectories?

Thanks

Upvotes: 1

Views: 56

Answers (1)

Jon Lin
Jon Lin

Reputation: 143856

Try changing the pattern in your rule from ^([^/\.]+)/?$ to ^([^\.]+)/?$ so that it matches against slashes.

Upvotes: 1

Related Questions