的.htaccess重写子域 [英] .htaccess rewrite subdomains

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

问题描述

下面是我目前的code:

Here is my current code:

RewriteCond %{HTTP_HOST} !^example\.com [NC] 
#RewriteCond %{REQUEST_URI}!^something
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com 
RewriteRule (.*) something/%1/$1 [QSA,L]

我的目标是改写的http://*.example.com/whatever http://example.com/something/* /不管,假设 * 是相同的两个和任何是相同的两个。不过,我相信这是造成一个无限循环不知何故,所以我补充说,注释掉线(的RewriteBase是/ BTW),但如果我取消,那么整个网站是一个500响应code。如果没有这一行,只有子域错误。

My goal is to rewrite http://*.example.com/whatever to http://example.com/something/*/whatever, assuming * is the same for both and whatever is the same for both. However, I believe this is causing an infinite loop somehow, so I added that commented out line (RewriteBase is / btw), but if I uncomment then the entire site is a 500 response code. Without that line, only the subdomains error.

我在做什么错了,我怎么能解决这个问题?我已经配置了服务器,所以,只要被重定向到我的public_html文件夹中。

What am I doing wrong, and how can I fix this? I have already configured the server so anything gets redirected to my public_html folder.

编辑:为了澄清,我试图做一个内部重定向,而不​​是外部

For clarification, I am trying to do an internal redirect, not external.

编辑:没有一个标志内部重定向看来。有没有我可以看到破碎的重写规则的实际错误消息的任何地方吗?如果我知道什么是错了,我将能够有更好的机会修复它。

There is not a flag for internal redirect it seems. Is there any place I can see the actual error message for the broken rewriterule? If I knew what was wrong I would be able to stand a better chance of fixing it.

推荐答案

我不明白规则重写域;也许这是你的问题。用你的code,试试:

I don't see the rule rewriting the domain ; maybe this is your problem. Using your code, try:

RewriteCond %{HTTP_HOST} !^example\.com [NC] 
#RewriteCond %{REQUEST_URI}!^something
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com 
RewriteRule (.*) http://example.com/something/%1/$1 [QSA,L]

我希望这将帮助你 杰罗姆·瓦格纳

I hope this will help you Jerome WAGNER

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

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