简体   繁体   中英

.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 ie I want to redirect http://www.thefutureshop.com.pk/index.php
to
http://thefutureshop.com.pk

My site is built using codeigniter.

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]

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM