I am administrating an Apache/2.2.15 webserver with several virtual hosts.
For one of these hosts I want to always prepend a missing www.
. Besides that, I want to add several short-cut URLs.
Here is what I have done so far:
RewriteEngine On
Redirect /short /some-long-URL
RewriteCond %{HTTP_HOST} ^my-domain\.org$ [NC]
RewriteRule ^.*$ http://www.%{SERVER_NAME}$1 [R=301]
With these rules, accessing an URL of the form http://my-domain.org/some-URL
is rewritten and redirected to http://www.my-domain.org/some-URL
, which is exactly what I want.
However, when accessing http://my-domain.org/short
, I get redirected to http://www.my-domain.org/
. It seems like the Redirect rule for /short
is never being applied... But accessing http://www.my-domain.org/short
is correctly being redirected to http://www.my-domain.org/some-long-URL
.
I hope someone knows a solution and can explain to me, what I am doing wrong.
Regards, Immanuel
PS: I would also appreciate it if the solution would also work with RewriteRule with PassThrough instead of a redirect :)