CodeIgniter Forums
How to hide index.php from URL for both www and without www on http/https on Amazone - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: How to hide index.php from URL for both www and without www on http/https on Amazone (/thread-64862.html)



How to hide index.php from URL for both www and without www on http/https on Amazone - MasoodRehman - 04-04-2016

I am facing the issue of index.php in url, when i visit the site with www then it displaying the index.php in url but without www its url is just fine no index.php in url for both protocol http and https on Amazon cloud server e.g

     Case 1:

     when i put www.example.com/mobiles in url and hit enter, then the url become like the following

     https://www.example.com/index.php/mobiles

     Case 2:

     when i put just example.com/mobiles in url and hit enter, then the url become like

     https://example.com/mobiles


Can we control this through .htaccess if yes then how?

Thanks.


RE: How to hide index.php from URL for both www and without www on http/https on Amazone - InsiteFX - 04-04-2016

You can get rid of the www by adding this to your .htaccess file:

Code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

See if that will work for you.


RE: How to hide index.php from URL for both www and without www on http/https on Amazone - MasoodRehman - 04-04-2016

(04-04-2016, 03:09 PM)InsiteFX Wrote: You can get rid of the www by adding this to your .htaccess file:

Code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

See if that will work for you.

I am already extracting www portion from url if some one put www.example.com .htaccess remove it and the url become example.com i am already doing this.

Problem Area:

My problem here is if one visit to mobiles page and put www with domain name e.g www.example.com/mobiles in this case when the user hit enter the page redirect to mobiles page successfully which is not the issue but if you look at the url the url will be showing like www.example.com/index.php/mobiles, if we put just example.com/mobiles then the url seems ok no index.php part in url, it gives issue only with www.


Thank you for your reply.



RE: How to hide index.php from URL for both www and without www on http/https on Amazone - InsiteFX - 04-05-2016

You could try capturing the url from the user and then doing a string replace on the www part of it.