【问题标题】:How to write a .htaccess file for sub domains which built with codeigniter framework如何为使用 codeigniter 框架构建的子域编写 .htaccess 文件
【发布时间】:2017-11-19 01:29:31
【问题描述】:

我的客户有一个名为“https://buzzbehind.com/”(主域)的域。还有一些子域。子域网址之一是“http://buzzmembers.buzzbehind.com”(BuzzMembers)。

实际上一个主域和子域都有 SSL 证书。因此,当我们使用“https”点击 URL 时,除了 BuzzMembers 之外,它们都可以正常工作。

如果我尝试使用 https 访问 BuzzMembers 的 URL,它会显示主域的不同子域 BuzzAdmin32 的布局。但网址是正确的。

Buzzbehind(主域)的Htaccess文件:

DirectoryIndex home.php index.html index.htm index.php

RewriteEngine On
RewriteRule ^(promotionalpage)/(index)/([^/]*)/([^/]*)/([^/]*)/$ https://buzz.buzzbehind.com/promotionalpage/index/$3/$4/$5/ [r=301,L]

RewriteRule ^(productdetails)/(index)/([^/]*)/([^/]*)/([^/]*)/$ https://buzz.buzzbehind.com/productdetails/index/$3/$4/$5/?current_url=https://buzz.buzzbehind.com/promotionalpage/index/$4/$3/$5 [r=301,L]

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

BuzzMember 的 Htaccess 文件:

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

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

BuzzAdmin32 进程:

#RewriteEngine on
#RewriteCond $1 !^(index\.php|images|robots\.txt)
#RewriteRule ^(.*)$ /index.php/$1 [L]

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

</IfModule>

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^www\.buzzadmin32\.buzzbehind\.com$
RewriteRule ^/?$ "http\:\/\/buzzadmin32\.buzzbehind\.com\/" [R=301,L]

我需要使用 https 运行 BuzzMembers 站点。现在它只适用于http。 请给我建议。

BuzzMembers 框架:Codeigniter

提前致谢。

【问题讨论】:

  • 您的意思是您需要buzzmembers.buzzbehind.com 才能使用 SSL 正常服务(地址栏上的绿色,而不是红色),对吗?然后您需要一个包含此主机名的证书,或者您需要一个通配符证书 *.buzzbehind.com 来提供所有服务。它与你在服务器上使用什么框架无关。
  • @KenCheung 请检查此链接 -> sslshopper.com/…
  • @KenCheung 我检查了所有关于 SSL 的设置都很好。但我希望这与 .htaccess 有关。
  • 其实我是用浏览器访问buzzmembers.buzzbehind.com,可以看到你的登录页面。有什么问题?我也尝试登录,它再次使用 URI /login 返回登录页面,听起来一切正常。
  • @KenCheung 否。这不是正确的页面。真实页面应该类似于buzzmembers.buzzbehind.com。如果您使用 https 而不是 http,那么您将看到登录表单。登录表单页面不正确。

标签: php .htaccess codeigniter ssl-certificate subdomain


【解决方案1】:

添加 RewriteBase /buzzmembers。

你可以用这个

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

【讨论】:

  • 根据您的建议,我刚刚在我的 BuzzMembers .htaccess 文件中添加了“RewriteBase /buzzmembers”行。但它现在正在工作。您是否代表“/buzzmembers”上的文件夹名称?是文件夹名还是什么?
  • 它的文件夹名称。如果我的代码有效,请将我的答案标记为正确(勾选我的答案)
  • 如果buzzmembers 是您的子域,那么只需添加我在.htaccess 中给出的代码。只有那 5 行。
  • @YadhuBabu 子域并不意味着 DocumentRoot 下的子文件夹。他们是不同的。从这个问题我猜httpd配置了VirtualHost并且每个主机名都有自己的DocumentRoot。
  • @Yadhu 是的,我只尝试了你的 5 行。但它不起作用。我也很困惑。
猜你喜欢
  • 2016-08-17
  • 2019-12-05
  • 2016-03-17
  • 2017-07-05
  • 2014-02-02
  • 2013-06-22
  • 1970-01-01
  • 2015-10-09
  • 2015-06-03
相关资源
最近更新 更多