Currently I have htaccess which removes index.php from URL, its working fine. But now I want to force url to start with www
.
My current code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
I tried following code, but its not working:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
#RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI}/index.php?/$1 [R=301,L]
But its not working, I am using codeigniter
Change order of your rule and keep redirects before rewrite rules: