Sorry for this basic question but dealing with apache is a long time ago.
A subfolder has moved from /download
to /images/download
.
I now like to rewrite it in .htaccess.
RewriteCond %{REQUEST_URI} ^/download/$
RewriteCond %{REQUEST_URI} !^/download/images$
RewriteRule (.*) /images/download/$1 [R=302,L]
I would expect that
http://example.com/download/literatur/a/online.pdf
would be rewritten to
http://example.com/images/download/a/online.pdf
but it is not. Rewrite in general is working (mod_rewrite is enabled). What do I oversee?
Your 1st rewrite condition is making your rule always fail because URI is not just /download
it is actually /download/<whatever-else>
.
You can use this rule instead in site root .htaccess:
RewriteEngine On
RewriteRule ^download/ /images%{REQUEST_URI} [R=302,L,NC,NE]
This rule will match any URI that starts with /download/
and will redirect this request to /images/<URI>