簡體   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