【问题标题】:Subdomain does not work after .htaccess rewrite.htaccess 重写后子域不起作用
【发布时间】:2016-02-09 22:52:05
【问题描述】:

我的问题有点难以解释,但我会尝试...

我在一家提供多种服务的网络酒店上有一个 php 网站 (www.mypage.com)。其中之一是照片库。画廊的标准网址是 gallery.mypage.com。到目前为止一切顺利!

最近我使用本指南使网站 SEO 友好(搜索引擎优化):http://www.desiquintans.com/cleanurls 它工作正常,但由于我重写了 .htaccess 文件中的 url,“gallery”的子域不再工作。

网络酒店支持人员不想提供帮助,或者他们不知道如何解决。你们知道是否有办法像我一样篡改 .htaccess 文件并且仍然能够访问子域?

这是 .htaccess 文件。前两行试图解决这个问题,但没有奏效。

RewriteCond %{HTTP_HOST} ^gallery\.mypage\.com$ [NC]
RewriteRule ^((?!sub1/).*)$ /sub1/$1 [L,NC]

# For Rewrite
Options +FollowSymLinks

# Turn Rewrite Engine on
RewriteEngine on

# Simple links (news, contact) [/news, /contact]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1

【问题讨论】:

  • 您必须向我们展示您的 .htaccess 文件
  • @Neat,在 OP 中添加了代码。

标签: php .htaccess rewrite


【解决方案1】:

在您的 .htaccess 中尝试此代码:

# For Rewrite
Options +FollowSymLinks

# Turn Rewrite Engine on
RewriteEngine on

RewriteCond %{HTTP_HOST} ^gallery\.mypage\.com$ [NC]
RewriteRule ^((?!sub1/).*)$ sub1/$1 [L,NC]

# Simple links (news, contact) [/news, /contact]
RewriteCond %{HTTP_HOST} !^gallery\. [NC]
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]

【讨论】:

  • 谢谢,成功了。连同我的代码。似乎第一个 Cond/Rule 行在错误的位置......
猜你喜欢
  • 2018-10-16
  • 2015-10-31
  • 2014-02-17
  • 1970-01-01
  • 2011-05-15
  • 2011-02-04
  • 2014-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多