【发布时间】:2020-11-28 18:10:13
【问题描述】:
我有 codeigniter 项目,我有 .htaccess 和以下内容:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
现在我想保留这个,因为我不想在地址栏中出现index.php。
我有一个域名example.com。现在,当我尝试https://www.example.com 时,它必须重定向到https://example.com。
如何使用上面的 .htaccess 文件来做到这一点?
【问题讨论】:
-
不。不工作。我收到 404 错误。对于这个网址:example.com/abc
-
抱歉,不清楚您在问什么。
Now I want to keep this index.php as I do not want index.php in addressbar是什么意思? -
@AmitVerma 我认为他们的意思是他们想要保留重写规则:
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] -
是的@Vickel 你是对的。
标签: regex .htaccess mod-rewrite