apache2 - how to exclude alias from rewrite rules?
Solution 1
Exclude the URIs containing "/phpmyadmin/" if you don't want them redirected:
RewriteCond %{REQUEST_URI} !/phpmyadmin/.*
Solution 2
Or just move the declaration of your Alias before Directory or Location
Alias /phpMyAdmin /var/(...)
<Location />
RewriteEngine on
# (...)
</Location>
By the wa: use Location with url ('/'), not 'Directory'.
Related videos on Youtube
James Nine
Updated on September 18, 2022Comments
-
James Nine almost 2 years
I have setup mod_rewrite and mod_alias on Apache2 on Debian (in a test server).
I have the following rewrite code in
/etc/apache2/sites-available/default
:<Directory /> Options FollowSymLinks AllowOverride All RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|html|css|js|gif|png|jpe?g)$ RewriteRule (.*)$ /index.php [L] </Directory>
I have the following alias code that is setup by default from the phpmyadmin package (loaded via
apt-get install phpmyadmin
and located in/etc/apache2/conf.d/phpmyadmin.conf
):Alias /phpmyadmin /usr/share/phpmyadmin
Everytime I load http://my.test.server/phpmyadmin, it goes to http://my.test.server/index.php and not the alias (which is bypassed/ignored?).
How do I setup an exclusion rule to allow aliases to pass through (even if the alias is setup in a different file?)
-
nyet about 6 yearsThe above advice to reorder Alias vs Rewrite does not work, regardless of the order of the conf file, Rewrite always happens before Alias.