Base url in CodeIgniter HMVC lose www in secondary module

457 Views Asked by At

I have a question please... this is my project where I use CI 3x HMVC in Linux hosting I have an error:

.htaccess is this:

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)

In my file config.php I have this line:

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

When I load https://www.myserver.com/ in the main "module" (front) I see in all my forms that all have this format:

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

The problem is when I load the https://www.myserver.com/admin module... I see in all my forms that have this format...

The difference is in "ADMIN" that my base_url is https://myserver.com/ Without WWW.

What is wrong? Can you help me please?

I need to solve this problem and keep my URL server with WWW in Front and Admin modules.

Thanks!

1

There are 1 best solutions below

4
AbdulAhmad Matin On BEST ANSWER

use this instead of that. so replace your .htaccess code with this code.

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

for change HTTP to HTTPS try this.

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