Amir
Amir

Reputation: 1

.htaccess redirect URL and remove .php

My current .htaccess file is like this It hides .php from the url.

RewriteEngine on
RewriteBase    /
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Now I want to redirect my site to also remove www i.e I want to redirect http://www.thefutureshop.com.pk/index.php
to
http://thefutureshop.com.pk

My site is built using codeigniter.

Upvotes: 0

Views: 330

Answers (2)

Ricky
Ricky

Reputation: 568

Try this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Replace:

$config['index_page'] = "index.php"
to
$config['index_page'] = ""

For more Read this http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/

Upvotes: 0

Croises
Croises

Reputation: 18671

You can use:

RewriteEngine on
RewriteBase    /
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Upvotes: 1

Related Questions