子域中的.htaccess
我正在尝试按如下方式设置子域:
http://subdomain.domain.com 应该加载什么真的 http://subdomain.domain.com/index.php/contest/
< a href="http://subdomain.domain.com/stepone" rel="nofollow">http://subdomain.domain.com/stepone 应该加载真正的 http://subdomain.domain.com/index.php/contest/stepone
http://subdomain.domain.com/images/example.jpg 应该加载 http://subdomain.domain.com/images/example.jpg 照常。
我之前已经在主域的子目录中完成了这一切设置并工作,但现在我尝试在子域上执行此操作,但它停止工作了。
这是我的 .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|javascript|email|robots\.txt|test\.php|terms\.html)
RewriteRule ^(.*)$ /index\.php/contest/$1 [L]
请帮助我!
I'm trying to set up a subdomain as follows:
http://subdomain.domain.com should load what is really http://subdomain.domain.com/index.php/contest/
http://subdomain.domain.com/stepone should load what is really http://subdomain.domain.com/index.php/contest/stepone
http://subdomain.domain.com/images/example.jpg should load http://subdomain.domain.com/images/example.jpg as normal.
I've had this all set up and working in a subdirectory on the main domain before but now that I'm trying to do it on a subdomain it's stopped working.
Here is my .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|javascript|email|robots\.txt|test\.php|terms\.html)
RewriteRule ^(.*)$ /index\.php/contest/$1 [L]
Please help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重写规则是否有效?即,您是否有
AllowOverride All
或虚拟主机的某些内容,如下所示:另外,看看 Gumbo 对这个问题的评论:
Are rewrite rules working at all? I.e. do you have
AllowOverride All
or something for virtual hosts, as per:Also, take a look this comment by Gumbo on this SO question:
Drupal .htaccess 文件是将 /?q=query 映射到 /query 的一个很好的示例,但不重定向提供显式文件/目录匹配的内容。以下是 Drupal 的 .htaccess 中的相关片段,其中 ?q= 更改为 index.php/contest/。
如果您需要限制域,使其不会正常重定向而仅从一个域重定向,请在
RewriteRule
之前插入以下内容:The Drupal .htaccess file is a good example of mapping /?q=query to /query, but not redirecting things which provide an explicit file/directory match. Here's the relevant snippet from Drupal's .htaccess with ?q= changed to index.php/contest/.
If you need to restrict the domain so that it doesn't redirect normally but just from the one domain, insert before the
RewriteRule
this:我想我已经找到了答案:
有什么理由我不应该像这样使用强制代理吗? (它会减慢速度吗?)
谢谢你们的回答。
I think I have found the answer using:
Is there any reason I shouldn't use the force proxy like this? (Does it slow things down?)
Thanks for your answers guys.