.htaccess 在 Linux 服务器 1 上不起作用,但在服务器 2 上起作用?
我制作了一个 .htaccess,在所有主机上使用它,直到这台主机将 index.html 重写到根域。
这是代码,
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.domain.co.uk/ $1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.domain.co.uk/ $1 [R=301,L]
RewriteEngine on
RewriteBase /
RewriteRule ^index\.(htm|html|php) http://www.domain.co.uk/ [R=301,L]
RewriteRule ^(.*)/index\.(htm|html|php) http://www.domain.co.uk/$1/ [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.co.uk
RewriteRule ^(.*)$ http://www.domain.co.uk/$1 [R=permanent,L]
但可惜的是,当它们仍然是同一台服务器时,它无法在 vidahost.com 上运行,并且该代码已在服务器上运行多年,所以我怀疑这是一个过时的服务器升级问题。
他们也做不到,我也被困住了。提前感谢所有帮助。
I have made a .htaccess that I've used on all hosts up until this one to rewrite index.html to the root domain.
This is the code
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.domain.co.uk/ $1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.domain.co.uk/ $1 [R=301,L]
RewriteEngine on
RewriteBase /
RewriteRule ^index\.(htm|html|php) http://www.domain.co.uk/ [R=301,L]
RewriteRule ^(.*)/index\.(htm|html|php) http://www.domain.co.uk/$1/ [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.co.uk
RewriteRule ^(.*)$ http://www.domain.co.uk/$1 [R=permanent,L]
But alas it will not work on vidahost.com when they are still supposedly same server and this code has worked on servers for years so I doubt it's an out of date server upgrade problem.
They can't do it either and I'm stuck. All help thanked in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是 Apache 配置问题——您必须被允许在主 Apache 配置中使用 mod_rewrite。
另外,RewriteEngine 通常应该位于任何其他 mod_rewrite 命令之前,尽管如果它之前对您有用,也许这不是这里的问题。
This could be an Apache configuration issue -- you have to be permitted to use mod_rewrite in the main Apache configuration.
Also, RewriteEngine should typically be before any other mod_rewrite commands, though if it was working for you before, maybe that's not the issue here.
好吧,首先,您应该发布虚拟主机配置,并且您还可以启用模式重写调试。
它可以帮助您找出问题所在。
Well, first, you should post virtual host configuration and also you can enable mode rewrite debugging.
It can help you to find out what wrong is.