CodeIgniter Forums
keep "www" in url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: keep "www" in url (/showthread.php?tid=76645)



keep "www" in url - the_steff - 06-05-2020

Hi !

I've got a problem with routing (once again).

Structure of my project :

Code:
/www
         /app
         /public
                /css
                /images
                /ressources

         /system
         /writable

In App.php

PHP Code:
public $baseURL 'https://www<my_domain>.com/';
public 
$indexPage ''

I've set up my mutu server in order to point to "./www/public".

I put .htaccess from my public directory to "./www" and I've commented lines in order to keep "www" in urls. The reason is because I conclude that my mutu server only redirect url starting with "www" to "./www/public" and not the other ones. Therefore, when original .htaccess removes "www" from "www.<domain>.com" to "<domain>.com" and redirect, it shown my root directory "./www" because (I think) in that case the server don't do the redirection to "./www/public".


Code:
# Rewrite "www.example.com -> example.com"
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

With that config, my home page is working fine with url request like
  • <domain>.com                          => forbidden but it's not a problem for me
The problem is other url don't work except if there's an explicit "index.php" Is it causing by keeping "www" in urls ?
I've test with indexPage = "index.php" in App.php and it's working fine but url are ugly AND I've had same "file not found" results with "return redirect()->back();" command.

Thanks for the help !


RE: keep "www" in url - InsiteFX - 06-07-2020

This will show you how to do almost anything.

Stupid .htaccess Tricks