子域htaccess
我这里有一个我希望传递的子域。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是正常的,您访问 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]
确保 Apache 重写模块处于活动状态,并且您的 .htaccess 文件在任何重写规则之前具有以下行:
Make sure Apache rewrite module is active and your .htaccess file has the following line before any rewrite rule:
假设您启用了
mod_rewrite
,您的RewriteRule
会导致无限重定向循环,这超出了最大重定向次数并导致内部服务器错误。您需要调整您的规则,使其仅重写一次。例如,这应该有效:
Assuming you have
mod_rewrite
enabled, yourRewriteRule
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: