Forum Moderators: phranque
I've inherited a web server and I have a slightly noobish question. I need to redirect a website I host to an external url. This is working fine with a .htaccess file in the sites directory. What I can't seem to get working is the original virtualhost non-www redirection.
Here's what I had originally in httpd.conf:
<VirtualHost *:80>
ServerName www.old-site.com
DocumentRoot /var/www/old-site
ErrorLog logs/old-site.com-error_log
TransferLog logs/old-site.com-access_log
</VirtualHost>
<VirtualHost *:80>
ServerName old-site
RewriteEngine on
RewriteRule ^/(.*)$ [old-site.com...]
</VirtualHost>
I added the following to enable my .htaccess file:
<Directory>
Options FollowSymLinks
AllowOverride All
</Directory>
My .htaccess file looks like this:
<Files ~ "^.(htaccess¦htpasswd)$">
deny from all
</Files>
Redirect permanent / [new-site...]
order deny,allow
All I need now is for requests to http: //old-site to be redirected to http: //www.new-site the same way that [old-site.com...] is.
Any help is appreciated!
<VirtualHost *:80>
ServerName www.old-site.com
[i]ServerAlias old-site.com[/i]
DocumentRoot /var/www/old-site
ErrorLog logs/old-site.com-error_log
TransferLog logs/old-site.com-access_log
Redirect 301 / http://www.new-site.com/
</VirtualHost>
#
[i]# Commented-out entire "old-site.com" vHost
#<VirtualHost *:80>
#ServerName old-site
#RewriteEngine on
#RewriteRule ^/(.*)$ http://www.old-site.com/$1
#</VirtualHost>[/i]
Jim
<VirtualHost *:80>
ServerName example.net
ServerAlias www.example.net example.net
Redirect 301 / http://www.example.edu/
</VirtualHost>
When I go into that VHost detail screen (using Webmin) it shows that a 301 redirect was created. However it still loads example.net instead of redirecting.
Oops - edited out IP.
[edited by: BradleyT at 4:09 pm (utc) on May 8, 2008]
Did you completely-flush your browser cache before testing this redirect? If not, your browser will serve the page from its cache, and no request will be sent to your server, so your code can have no effect.
Jim