【问题标题】:.htaccess code to affect main domain only.htaccess 代码仅影响主域
【发布时间】:2015-02-03 23:45:03
【问题描述】:

我有两个域。 1) 主域 2) 子域。 .htaccess 文件中的这段代码给我带来了问题。

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^ index.php [L]

按原样,这两个站点上的一切看起来都很完美,并且对于最终用户来说运行顺畅。但是,此代码意味着我们无法对主域进行任何管理员更改(页面编辑、创建内容等)。

如果我“取消注释”底部 4 行,我可以更改主域,但子域不再指向相应的主题文件。

是否可以“取消注释”底部 4 行并让它只影响主域?

【问题讨论】:

    标签: .htaccess mod-rewrite subdomain


    【解决方案1】:

    你可以使用这个.htaccess

    RewriteCond %{HTTP_HOST} !^subdomain\.example.com$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^ index.php [L]
    

    排除子域。

    【讨论】:

    • 不客气,很高兴它成功了。您可以通过单击我的答案左上角的勾号将答案标记为已接受。
    • 我打了勾 - 这样的 stackoverflow 菜鸟。我认为我做得对。
    • 取笑我的英语不好 ;-)
    猜你喜欢
    • 1970-01-01
    • 2013-09-25
    • 2015-04-06
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 1970-01-01
    • 2015-05-09
    相关资源
    最近更新 更多