Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Codeginter 301重定向_.htaccess_Codeigniter_Mod Rewrite - Fatal编程技术网

.htaccess Codeginter 301重定向

.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

我有一个正在运行的网站。它开始使用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 %{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]