I want to redirect rewrite /zp-core/admin.php to admin but somehow I can’t get it to work.
I’ve added this rule to my htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^/admin$ /zp-core/admin.php [L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^albums/?(.+/?)?$ $1 [R=301,L]
...
# Catch-all - everything else gets handled in PHP for compatibility.
RewriteRule ^(.*)/?$ index.php?album=$1 [L,QSA]
The third rule should do it, but somehow it doesn’t. In the end it falls back on the catch all rule
When you say “rewrite A to B“, usually, “A” is what the user types and “B” is where you want him to get.
If A=’
/admin‘ and B=’/zp-core/admin.php‘ then the first rule is ok, if you remove other rules, it will work.The problem is – apache looks into .htaccess on every request, including sub-requests, and your redirect does a sub-request… So it does not match the first rule anymore, but then comes the catch-all rule, and it is a match again (you’ll see that
$_GET["album"]will be/zp-core/admin.phpwhen hitting index.php on such request.What you need to do is to add
RewriteCondeither checking that the uri is not/zp-core/admin.phpOR that you’re not in sub-request…Either:
OR: