Reputation: 328
.htaccess file:
I have the following htaccess file (it's very short):
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_]+)/?$ index.php?page=$1 [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_]+)/(.+)/?$ index.php?page=$1¶ms=$2 [L]
I think is easy to understand it: if a file doesn't exists, then the url is rewrited.
The problem:
An "error" folder or file doesn't exists so it should be rewrited. However, when I try to access to url.local/error/404
don't works, but url.local/error
works.
Maybe a problem with Apache?
Edit:
Summary:
http://url.local/dir
workshttp://url.local/dir/subdir
workshttp://url.local/dir/subdir/subdir
workshttp://url.local/error
workshttp://url.local/error/subdir
don't worksUpvotes: 0
Views: 56
Reputation: 785246
Maybe a problem with Apache?
No there is no Apache problem. Issue is that your regex is not matching /
but your input has one.
Have it this way:
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(\w+)/(.+)/?$ index.php?page=$1¶ms=$2 [L]
RewriteRule ^(.+?)/?$ index.php?page=$1 [L,QSA]
Upvotes: 1