SUMER KOLCHAK SUMER KOLCHAK - 2 months ago 14
Apache Configuration Question

MOD_REWRITE (RewriteCond) suppose to ignore domain.tld/1 given DirectoryIndex is "1"

if it begins with 0 to 9 then ignore
if it begins with z then ignore.


that is what this mod-rewrite code says..

<Directory "/0/2/2">
Options FollowSymLinks
AllowOverride All
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/([0-9])$
RewriteCond %{REQUEST_URI} !^/z$
RewriteRule ^(.*) /z [L]
</Directory>


the directory index is "1"

DirectoryIndex 1


in the httpd.conf

which means when i go to

domain.tld/


this should be same as

domain.tld/1


and thus ignored by the mod-rewrite rule above.

but it is not ignoring it..

.. it ignores domain.tld/1 just fine..

but won't ignore

domain.tld/

Answer Source
if it begins with 0 to 9 then ignore
if it begins with z then ignore.
that is what this mod-rewrite code says..

Actually, it doesn't quite say that, because $ is the end-of-string anchor. Here are some tweaks. The two conds are rolled into one, and the /1 folder check is in the rule.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/?[z0-9] [NC]
RewriteRule ^/(?!1)(.*) /z [L,NE]

This assumes that this lives in httpd.conf. If it lives in .htaccess, change the rule like so:

RewriteRule ^/?(?!1)(.*) z [L,NE]