Linux Apache重定向表单服务器别名,尽管它显然不应该';T
根据,Apache不应该简单地从其他ServerAlias域重定向到ServerName域,但在我的例子中,它确实如此 例如,当我访问www.yannbane.net(我的一个域指向服务器的IP)时,它会将我重定向到yannbane.com。当我访问www.yannbane.com时,它也会重定向到yannbane.com 这是我真正想要的行为,但我不明白这里发生了什么 以下是我的站点配置:Linux Apache重定向表单服务器别名,尽管它显然不应该';T,linux,wordpress,apache,redirect,dns,Linux,Wordpress,Apache,Redirect,Dns,根据,Apache不应该简单地从其他ServerAlias域重定向到ServerName域,但在我的例子中,它确实如此 例如,当我访问www.yannbane.net(我的一个域指向服务器的IP)时,它会将我重定向到yannbane.com。当我访问www.yannbane.com时,它也会重定向到yannbane.com 这是我真正想要的行为,但我不明白这里发生了什么 以下是我的站点配置: <VirtualHost *:80> ServerName yannbane.com
<VirtualHost *:80>
ServerName yannbane.com
ServerAlias yannbane.net yannbane.org www.yannbane.net www.yannbane.org www.yannbane.com
DocumentRoot "/var/www/yannbane.com/wordpress"
ErrorLog "/var/log/yannbane.com/wordpress/error.log"
</VirtualHost>
服务器名yannbane.com
ServerAlias yannbane.net yannbane.org www.yannbane.net www.yannbane.org www.yannbane.com
DocumentRoot“/var/www/yannbane.com/wordpress”
ErrorLog“/var/log/yannbane.com/wordpress/error.log”
这里是apache2.conf:
ServerName localhost
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
ServerName本地主机
互斥文件:${APACHE\u LOCK\u DIR}默认值
PidFile${APACHE_PID_文件}
超时300
继续
MaxKeepAliveRequests 100
保持超时
用户${APACHE\u RUN\u User}
组${APACHE\u RUN\u Group}
主机名查询
ErrorLog${APACHE_LOG_DIR}/error.LOG
日志级别警告
#包括模块配置:
包括可选mods启用/*.加载
IncludeOptional mods enabled/*.conf
#包括要侦听的端口列表
Include ports.conf
选项如下符号链接
不允许超限
要求全部拒绝
不允许超限
要求所有授权
选项索引跟随符号链接
允许超越所有
要求所有授权
AccessFileName.htaccess
要求全部拒绝
日志格式“%v:%p%h%l%u%t\%r\“%>s%O\”%{Referer}i\“\”%{User-Agent}i\\”vhost\u
日志格式“%h%l%u%t\%r\”%>s%O\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\“%>s%O”通用
日志格式“%{Referer}i->%U”Referer
日志格式“%{User agent}i”代理
IncludeOptional conf enabled/*.conf
IncludeOptional sites enabled/*.conf
以下是我的WordPress目录中的my.htaccess(这是此虚拟主机的文档根):
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
有人能告诉我为什么会发生这些重定向吗?实现这种行为的适当方式是什么?您可以在.htaccess中添加以下代码,以使用www重定向域
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
实际上这将有助于在新域上重定向,在这里我们可以使用www.yannbane.com而不是www.newdomain
您可能在
.htaccess
文件中有额外的相关配置,因为您有一个允许从/var/www
覆盖所有的,但我该如何确切地调查呢?无论是哪种情况,我现在都已将我的WordPress.htaccess
文件内容添加到问题中……WordPress会这样做,与Apache配置无关。因为我没有运行WP,所以请查看一下它的配置,看看是否可以禁用它。(你甚至可以测试这个:创建一个static test.html页面,我敢打赌它不会被重定向,因为它不是通过WP的框架运行的)。@Wrikken-你为什么不把它作为一个答案发布,这样我就可以接受它?我刚刚检查过,是的,WordPress正在执行重定向。我可以在主设置部分更改它,因此理论上它可以指向www.yannbane.com
。
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]