Welcome Guest, Not a member yet? Register   Sign In
How to hide index.php from URL for both www and without www on http/https on Amazone
#1

(This post was last modified: 04-04-2016, 01:05 PM by MasoodRehman.)

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.
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.
Reply
#4

You could try capturing the url from the user and then doing a string replace on the www part of it.
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