I have what, from my searching so far, seems to be a slightly different problem with site redirections than the norm. I need to redirect one particular route from one domain to another on a different port.
So far I've tried a simple 301 Redirect and a rewrite to no avail.
The code looks like
<VirtualHost *:80>
ServerName blah.hardsoft.nexus.blah2.blah3.au/phpmyadmin
RewriteEngine on
RedirectMatch "^blah.*nexus.*\/phpmyadmin$" "http://10.1.140.1:8080/phpmyadmin"
#RedirectMatch ".*nexus.*" "http://10.1.140.1:8080/phpmyadmin"
#Redirect 301 / http://10.1.140.1:8080/phpmyadmin
</VirtualHost>
<VirtualHost 10.1.140.1:8080>
ServerName phpmyadmin
DocumentRoot /var/www-8080
</VirtualHost>
As you can see I've tried a couple of redirect matches (one very broad) and a 301 redirect, but in all cases what I end up with is it being redirected to
10.1.140.1/phpmyadmin
without the port being appended (at least I think that's whats happening).
Any idea how I should be doing this? Is it even possible?
You can use
mod_rewrite
for redirection with port number. First, enablemod_rewrite
in your server (a2enmod rewrite
), then add this to your config:I guess the URL to be redirected starts with "/phpadmin", that's why I used the "^" in the regex. If this is wrong, then change the rule accordingly.
Flags used:
[L]
- last rule, no further processing takes place[R=301]
- Redirect permanent[NE]
- no encoding of special charactersThen restart your server and test.
EDIT: Just saw that you had a
RewriteEngine on
in your config, somod_rewrite
is probably already enabled. Note that you only needmod_alias
for aRedirect
orRedirectMatch
!