.htaccess Codeginter 301重定向
我有一个正在运行的网站。它开始使用url中的index.php。我已经去掉了它,但为了不复制内容,我需要在可能存在的仍然使用index.php的任何现有路径上执行301重定向 我的.htaccess文件如下所示:.htaccess Codeginter 301重定向,.htaccess,codeigniter,mod-rewrite,.htaccess,Codeigniter,Mod Rewrite,我有一个正在运行的网站。它开始使用url中的index.php。我已经去掉了它,但为了不复制内容,我需要在可能存在的仍然使用index.php的任何现有路径上执行301重定向 我的.htaccess文件如下所示: RewriteEngine on RewriteCond $1 !^(index\.php|robots\.txt|public|) # Prevent CI index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{R
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|public|)
# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteRule ^register /index.php/register/ [L]
这对domain.com/register很有效
我怎样才能让domain.com/index.php/register也转到301,但仍然只在地址栏中保留domain.com/register
提前感谢。尝试将此添加到最顶部(就在
上的重写引擎下方)
:
快到了!!domain.com/index.php/register现在在地址栏中重写为domain.com//register。有没有办法删除不需要的正斜杠??Thanks@lunchboxbill是的,将
index\.php([^\?\]*)
更改为index\.php/([^\?\]*)
RewriteCond %{THE_REQUEST} \ /+index\.php([^\?\ ]*)
RewriteRule ^ /%1 [L,R=301]