子域中的.htaccess

发布于 2024-10-03 12:47:29 字数 1060 浏览 1 评论 0原文

我正在尝试按如下方式设置子域:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别忘他 2024-10-10 12:47:29

重写规则是否有效?即,您是否有 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:

梅窗月明清似水 2024-10-10 12:47:29

Drupal .htaccess 文件是将 /?q=query 映射到 /query 的一个很好的示例,但不重定向提供显式文件/目录匹配的内容。以下是 Drupal 的 .htaccess 中的相关片段,其中 ?q= 更改为 index.php/contest/。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/contest/$1 [L,QSA]

如果您需要限制域,使其不会正常重定向而仅从一个域重定向,请在 RewriteRule 之前插入以下内容:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]

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/.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/contest/$1 [L,QSA]

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:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
寄与心 2024-10-10 12:47:29

我想我已经找到了答案:

RewriteRule ^(.*)$ subdomain.domain.com/index\.php/contest/$1 [L, P]

有什么理由我不应该像这样使用强制代理吗? (它会减慢速度吗?)

谢谢你们的回答。

I think I have found the answer using:

RewriteRule ^(.*)$ subdomain.domain.com/index\.php/contest/$1 [L, P]

Is there any reason I shouldn't use the force proxy like this? (Does it slow things down?)

Thanks for your answers guys.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文