Welcome Guest, Not a member yet? Register   Sign In
Base url in CodeIgniter HMVC lose www in secondary module
#1

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

 is this:


Code:
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)

 Run code snippet
Expand snippet


In my file config.php I have this line:
Code:
$config['base_url'] = 'https://www.myserver.com/';

When I load 
Code:
https://www.myserver.com/

 in the main "module" (front) I see in all my forms that all have this format:

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

The problem is when I load the 
Code:
https://www.myserver.com/admin

 module.... I see in all my forms thar have this formar....


The difference is in "ADMIN" that my base_url is 
Code:
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.


Recently I have changed my Htaccess by this code:


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>



But it worst... This code gives me a lot of errors like this: myserver.com/listar-resumen-estados/1/1 404 (Not Found) and others errors like this... cross domain Ajax...

Thanks! Ani
Reply
#2

Your redirecting to http not https.

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 ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

Finally, be consistent with the www subdomain in all links (either use it always or never).
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB