繁体   English   中英

.htaccess重定向URL并删除.php

[英].htaccess redirect URL and remove .php

我当前的.htaccess文件就是这样,它从网址中隐藏了.php。

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

现在,我想重定向我的网站以也删除www,即我想重定向http://www.thefutureshop.com.pk/index.php

http://thefutureshop.com.pk

我的网站是使用codeigniter构建的。

您可以使用:

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]

尝试这个

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

更换:

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

有关更多信息, 请参见http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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