子域htaccess

发布于 2024-09-07 12:02:09 字数 434 浏览 1 评论 0原文

我这里有一个我希望传递的子域。

here the example of url : http://subdomain.domain.com/login
and it should point to : http://subdomain.domain.com/index.php/login

我写了一个简单的 htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|images|robots\.txt|css|javascript)
RewriteRule ^(.*)$ index.php/$1 [L]

但我总是收到 500 服务器错误。有人知道我错在哪里吗?

感谢您的帮助

I have here a subdomain which i wish to pass on.

here the example of url : http://subdomain.domain.com/login
and it should point to : http://subdomain.domain.com/index.php/login

i write a simple htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|images|robots\.txt|css|javascript)
RewriteRule ^(.*)$ index.php/$1 [L]

but i always get 500 server error. any body have idea where i wrong?

thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

掐死时间 2024-09-14 12:02:09

这是正常的,您访问 http://subdomain.domain.com/login,被重定向到 < a href="http://subdomain.domain.com/index.php/login" rel="nofollow noreferrer">http://subdomain.domain.com/index.php/login,然后< a href="http://subdomain.domain.com/index.php/index.php/login" rel="nofollow noreferrer">http://subdomain.domain.com/index.php/index.php/login 等等,因为您的 RewriteRule 始终匹配。

你可以写 `RewriteRule ^([^/]*)$ index.php/$1 [L]

It's normal, you go to http://subdomain.domain.com/login, get redirected to http://subdomain.domain.com/index.php/login, then to http://subdomain.domain.com/index.php/index.php/login and so on because you RewriteRule always match.

You can write `RewriteRule ^([^/]*)$ index.php/$1 [L]

一指流沙 2024-09-14 12:02:09

确保 Apache 重写模块处于活动状态,并且您的 .htaccess 文件在任何重写规则之前具有以下行:

RewriteEngine On

Make sure Apache rewrite module is active and your .htaccess file has the following line before any rewrite rule:

RewriteEngine On
少女情怀诗 2024-09-14 12:02:09

假设您启用了 mod_rewrite,您的 RewriteRule 会导致无限重定向循环,这超出了最大重定向次数并导致内部服务器错误。

您需要调整您的规则,使其仅重写一次。例如,这应该有效:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]

Assuming you have mod_rewrite enabled, your RewriteRule causes an infinite redirection loop, which exceeds the maximum number of redirects and causes an internal server error.

You need to condition your rule so it only rewrites once. For example, this should work:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文