5

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?)

James Nine
  • 173
  • 1
  • 7

2 Answers2

4

Exclude the URIs containing "/phpmyadmin/" if you don't want them redirected:

RewriteCond   %{REQUEST_URI}  !/phpmyadmin/.*
Mathias R. Jessen
  • 24,907
  • 4
  • 62
  • 95
3

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'.

Vivien
  • 131
  • 1
  • The above advice to reorder Alias vs Rewrite does not work, regardless of the order of the conf file, Rewrite always happens before Alias. – nyet Jun 01 '18 at 22:42