阿帕奇VirtualDocumentRoot重定向不存在的域不存在、重定向、阿帕奇、VirtualDocumentRoot

由网友(夜呓)分享简介:使用VirtualDocumentRoot有多个域和子域我'。一切顺利的话,直到有人试图通过IP或不存在的域到达我的服务器。例如10.10.10.10至极的结果到一个404 Not Found错误。也许有人在那里可以帮助我找到一个解决方案,以重定向不存在的域名或IP到我的主域名www.example.com?我要明...

使用VirtualDocumentRoot有多个域和子域我'。 一切顺利的话,直到有人试图通过IP或不存在的域到达我的服务器。例如10.10.10.10至极的结果到一个404 Not Found错误。 也许有人在那里可以帮助我找到一个解决方案,以重定向不存在的域名或IP到我的主域名www.example.com?

我要明确指出:不存在的子域被重定向,但不存在的域不是

HTTPD.CONF:

 <虚拟主机*:80>
        服务器名称默认
        ServerAlias​​ *
        #www.example.com == /httpdocs/example.com/www/
        VirtualDocumentRoot /httpdocs/%-2.0.%-1/%-3
    < /虚拟主机>
 

/httpdocs/example.com/.htacces:

 #重写所有不存在的子域到www。
的RewriteCond%{HTTP_HOST}例如 .COM $
。重写规则^ * $ HTTP://www.example.com% {REQUEST_URI} [R = 301,L]
 

解决方案

解决我的问题是: 为此添加到.htacces在我的根目录文件夹/httpdocs/.htaccess 这将导致所有的非现有域结束运算在它们拾起htaccess的根文件夹。 (无符号链接了)

 #开启重写引擎
RewriteEngine叙述上

#重写所有不存在的域example.com
的RewriteCond%{HTTP_HOST}!例如 .COM $ [NC] #just此处添加您的主域名
。重写规则^ * $ HTTP://www.example.com% {REQUEST_URI} [R = 301,L]
 
用了权限管理ROOT了手机后怎样清除ROOT

I'am using VirtualDocumentRoot to have multiple domains and subdomains. Everything goes well until someone tries to reach my server by IP or an non-existing domain. For example 10.10.10.10 wich results into an 404 Not Found error. Maybe someone out there can help me find an solution to redirect non-existing domains or IP to my main domain www.example.com?

Let me be clear: non-existing subdomains are being redirected but non-existing domains are not.

HTTPD.CONF:

<VirtualHost *:80>
        ServerName default
        ServerAlias *
        #www.example.com == /httpdocs/example.com/www/
        VirtualDocumentRoot /httpdocs/%-2.0.%-1/%-3
    </VirtualHost>

/httpdocs/example.com/.htacces:

# Rewrite all non-existing subdomains to www.
RewriteCond %{HTTP_HOST} example.com$
RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [R=301,L]

解决方案

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]

阅读全文

相关推荐

最新文章