.htaccess :将初始输出重写回子域
我有以下 htaccess。
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www|m)\.DOMAIN\.com$
RewriteCond %{HTTP_HOST} ^([^\.]+).DOMAIN.com$
RewriteRule ^(.*)$ http://DOMAIN.com/index.php?id=%1 [NC,QSA,L,R=301]
问题是,虽然它有效,但我仍然需要它使用子域作为 URL。所以基本上现在我正在尝试将 DOMAIN.com/index.php?id=%1 重写回 SUDOMAIN.DOMAIN.com 以便用户在地址栏上看到他们请求的子域而不是 http://domain.com/index.php?id=user
我尝试过各种各样的事情,但总是结束某种无限循环。请帮忙!
我已经设置了通配符子域。与上面显示的 htaccess 结合使用。 子主干不会粘住,它会将自己重写为上面显示的长字符串。但我想做的是获取 url ro 保留 subdomain.domain.com 不幸的是,您发布的链接与我上面发布的链接几乎相同,似乎并不能真正让子域粘住。
有什么想法吗?
I have the following htaccess.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www|m)\.DOMAIN\.com$
RewriteCond %{HTTP_HOST} ^([^\.]+).DOMAIN.com$
RewriteRule ^(.*)$ http://DOMAIN.com/index.php?id=%1 [NC,QSA,L,R=301]
The problem is that although it works I need it to still use the subdomain as the URL. So basically now I'm trying to rewrite DOMAIN.com/index.php?id=%1 back into SUDOMAIN.DOMAIN.com so the user sees the subdomain they requested on the address bar and not the http://domain.com/index.php?id=user
I'ver tried all sorts of things but always end up with some sort of infinite loop. Please help!
I already have a wildcard subdomain set up. In conjunction with the htaccess shown above.
The submain doesn't stick, it rewrites itself into the long string shown above. But what im trying to do is get the url ro remain subdomain.domain.com unfortunately the link you posted does peretty much the same as what I have posted above, doesn't really seem to be able to get the sub-domain to stick.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您是否已经弄清楚,但您的最后一行(我相信)应该是这样的:
如果这不起作用,请尝试以下操作:
没有专家,但我有从我发现的其他代码中工作的子域。希望有帮助。
Not sure if you figured it out yet, but your last line (I believe) should be this:
If that does not work try this:
No expert but I have subdomains working from some other code I found. Hope it helps.
您需要先更改 DNS 设置。 (
A
记录)已经有一个
You need to change your DNS settings before. (
A
record)There is already an answer for that question.