htaccess的通配符子域 [英] .htaccess Wildcard Subdomains

查看:245
本文介绍了htaccess的通配符子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的.htaccess和通配符子域实​​现解决方案,使

I'm trying to implement a solution using .htaccess and wildcard subdomains so that

http://subdomain.example.com 被映射到的 http://example.com/index.php/accounts/subdomain/ 。我的规则看起来是这样的:

http://subdomain.example.com is mapped to http://example.com/index.php/accounts/subdomain/. My rules look something like:

RewriteCond %{HTTP_HOST} !www.example.com [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).example.com [NC]
RewriteRule ^(.*/) /index.php [PT,L]

这工作,但无视一切。当我尝试附加任何规则,例如:

Which works, but disregards everything else. When I try appending anything to the rule e.g:

RewriteRule ^(.*/) /index.php/hello [PT,L]

我得到一个500内部服务器错误。我如何得到这个工作?

I get a 500 internal server error. How do I get this working?

推荐答案

您可能需要排除的index.php 从您的规则:

You probably need to exclude the index.php from your rule:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.com$ [NC]
RewriteRule !^index\.php($|/) index.php/accounts/%2%{REQUEST_URI} [PT,L]

这篇关于htaccess的通配符子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆