.htaccess 在 Linux 服务器 1 上不起作用,但在服务器 2 上起作用?

发布于 2024-09-27 19:25:13 字数 742 浏览 2 评论 0原文

我制作了一个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎的声音 2024-10-04 19:25:13

这可能是 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.

小鸟爱天空丶 2024-10-04 19:25:13

好吧,首先,您应该发布虚拟主机配置,并且您还可以启用模式重写调试。

RewriteLog path-to-log-file
RewriteLogLevel number-0-9- /zero is disabled/

它可以帮助您找出问题所在。

Well, first, you should post virtual host configuration and also you can enable mode rewrite debugging.

RewriteLog path-to-log-file
RewriteLogLevel number-0-9- /zero is disabled/

It can help you to find out what wrong is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文