I am using HTTPS as the primary url and as per Google SEO guidelines I have to set the following redirects
- http://example.com/ to https://example.com
- http://www.example.com/ to https://example.com
- https://www.example.com/ to https://example.com
The redirects which I have configured are working perfectly for homepage. However for the internal pages, only the first is working while 2nd and 3rd are adding index.php in the url.
Example
https://www.example.com/index.php/mobiles/apple/apple-iphone-se to https://example.com/index.php/mobiles/apple/apple-iphone-se
I am using the following code in .htaccess
RewriteEngine On
#Block access for libwww-perl user-agent
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteBase /
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^52.34.179.108
RewriteRule (.*) https://priceoye.pk/$1 [R=301,L]
- Hosting: AWS (httpd)
- URL: PriceOye[dot]pk
2
Answers
Adding the following two lines above RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] resolved the issue
create a file in your project folder named ” .htaccess ”
then type this
then go to application > config > config.php
make it like this