Redirect 301从www.domain.com/index.html重定向到www.domain.com不工作
在apache配置文件(即httpd.conf)中,我们有虚拟主机配置,该配置在过去两年中一直有效。今天去那里没有问题。但当我被要求添加重定向时,它不起作用。我的虚拟主机Conataner看起来像这样Redirect 301从www.domain.com/index.html重定向到www.domain.com不工作,redirect,joomla,httpd.conf,Redirect,Joomla,Httpd.conf,在apache配置文件(即httpd.conf)中,我们有虚拟主机配置,该配置在过去两年中一直有效。今天去那里没有问题。但当我被要求添加重定向时,它不起作用。我的虚拟主机Conataner看起来像这样 <VirtualHost *:80> DocumentRoot /var/www/html ServerName domain.com Redirect 301 / http://www.domain.com/ Redirect 301 /index.html http
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName domain.com
Redirect 301 / http://www.domain.com/
Redirect 301 /index.html http://www.domain.com/
</VirtualHost>
DocumentRoot/var/www/html
ServerName域名.com
重定向301/http://www.domain.com/
重定向301/index.htmlhttp://www.domain.com/
我打字的时候在这里“http://domain.com“这需要时间”http://www.domain.com“预期行为。但是当我打字的时候”http://domain.com/index.html“或”http://www.domain.com/index.html“它不会带我去”http://www.domain.com“…这是joomla的网站
谁能帮我解决这个问题
提前感谢添加
ServerAlias www.domain.com
在
ServerName domain.com
之后的新行中,听起来好像是在尝试第二个重定向之前应用了第一个重定向。
您是否尝试过将重定向行按其他顺序排列
Redirect 301 /index.html http://www.domain.com/
Redirect 301 / http://www.domain.com/
通常,这是通过使用更通用的方法和mod_rewrite实现的: 此代码应放在域根目录下的htaccess文件中,即domain.com/.htaccess 或者虚拟主机配置
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
重新启动发动机
重写基/
重写cond%{HTTP_HOST}^domain\.com$
重写规则^(.*)$http://www.domain.com/$1[R=301,L]
(例如,这里也有)