How do you combine these 2.htaccess RewriteRules into one?
Okay, I have another question and I'm starting with this.
I have this RewriteRule, it redirects the request correctly, but prevents me from using other directories:
RewriteRule ^([0-9A-Za-z]+)/?$ /query.php?id=$1 [L]
and now this RewriteRule will skip all these directories, but now you need to comment out the above rule for that.
RewriteRule ^(css|js|admin|pages|includes|images)(/|$) - [L]
Can the two be combined? If so, how?
+2
source to share
2 answers
There's also this neat trick:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) query.php?id=$1 [L]
That is, if the file path is not an existing file or directory, submit a request to the PHP script (so you can load some module dynamically or show a useful 404 page).
0
source to share