【问题标题】:Base url in CodeIgniter HMVC lose www in secondary moduleCodeIgniter HMVC 中的基本 url 在辅助模块中丢失 www
【发布时间】:2019-02-02 06:24:15
【问题描述】:

我有一个问题请...这是我在 Linux 主机中使用 CI 3x HMVC 的项目我有一个错误:

.htaccess是这个:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
Options -Indexes


### Redirigir la URL sin www a con www ### 
RewriteCond %{HTTP_HOST} ^myserver.com
RewriteRule (.*) https://www.myserver.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^myserver.com [OR]
RewriteCond %{HTTP_HOST} ^www.myserver.com
RewriteRule (.*) https://www.myserver.com/$1 [R=301,L,QSA] #Falta www


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

RewriteCond $1 !^(index\.php|global|favicon\.ico|javascript)

在我的文件 config.php 中有这一行:

$config['base_url'] = 'https://www.myserver.com/';

当我在主“模块”(前面)中加载 https://www.myserver.com/ 时,我在所有表单中都看到了这种格式:

<form action="https://www.myserver.com/controllerxxxx" action="post"....

问题是当我加载https://www.myserver.com/admin 模块时...我在所有具有这种格式的表单中都看到...

区别在于“ADMIN”,我的 base_url 是 https://myserver.com/ 没有 WWW

怎么了?你能帮帮我吗?

我需要解决这个问题,并将我的 URL 服务器与 WWW 放在 Front 和 Admin 模块中。

谢谢!

【问题讨论】:

    标签: codeigniter mod-rewrite hmvc-codeigniter .htaccess


    【解决方案1】:

    用这个代替那个。所以用这个代码替换你的.htaccess代码。

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    </IfModule>
    

    将 HTTP 更改为 HTTPS 试试这个。

     RewriteEngine On
     RewriteCond %{HTTPS} !=on
     RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    

    【讨论】:

    • 这段代码给了我很多这样的错误:myserver.com/listar-resumen-estados/1/1 404 (Not Found) 和其他类似这样的错误......跨域Ajax......等
    • 谢谢...但在我的管理员/视图表单中,我看到了以下代码:
      myserver.com/admin/auth/login" method="post" accept-charset="utf-8"> 而我需要myserver... 我看到我的 Base_url 是 Admin 中的问题,它更改为 myserver.com ...但在 Front(main) 模块中是 www.myserver.com
    • 我给你一个屏幕截图来查看我的问题,谢谢!
    • 谢谢!!!我亲爱的朋友!这是我的错误...我输入了另一个配置... myserver.com 并且“管理员”正在使用此文件...对不起!!!你真美!!! (我必须删除这个有冲突的文件)
    猜你喜欢
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2011-08-22
    • 2015-11-05
    • 1970-01-01
    • 2014-03-25
    • 2016-04-05
    相关资源
    最近更新 更多