Apache VirtualDocumentRoot redirect non-existing domains

て烟熏妆下的殇ゞ 提交于 2019-12-08 05:25:29

The Solution to my problem was:
To add this to .htacces in my webroot folder /httpdocs/.htaccess

This will cause all non-existing domains to end op in root folder where they are picked up by the .htaccess. (no symbolic links anymore)

# Enable Rewrite Engine
RewriteEngine on

# Rewrite all non-existing domains to example.com
RewriteCond %{HTTP_HOST} !example\.com$ [NC] #just add your main domain here
RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [R=301,L]

There appears to be a "bug" in mod_vhost_alias whereby you can't specify a failover/default directory if the interpolated directory doesn't exist (see comments at the bottom of this page) so I don't think you can handle arbitrary domain names, you'll need to create directories for each of the domain names you want to match using your interpolation rules.

However, for the IP address, I believe if you create a symlink from this directory /httpdocs/230.239/132/ to /httpdocs/gdwebs.nl/www/ then that'll work.

Alternatively, if you can't create a symlink, create the /httpdocs/230.239/132/ directory and use htaccess to redirect requests.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!