2016-08-09 24 views
0

我在生成重定向规则时遇到了困难我尝试了很多可能的方法,但这些方法都不起作用。 下面是详细信息:想要为htaccess生成redirct规则

1)当前链接:https://app.abcd.com(在URL显示)

2)重定向到:https://app.abcd.com/index.php/login

3)应改名为:https://app.abcd.com/login

我有尝试过:

RewriteEngine on 
RewriteRule (.*) http://https://app.abcd.com/index.php/login/$1 [R=301,L] 

没有工作!

任何帮助!

+0

http://stackoverflow.com/questions/19183311/codeigniter-removing-index-php-from-url请检查这个链接 – kuldeep

回答

0

您可以使用此:

RewriteEngine on 

RewriteRule ^$ /index.php/login [L,R] 

这将重定向您的主页//index.php/login

您也可以使用RedirectMatch完成此操作

RedirectMatch 301 ^/$ /index.php/login/ 
0

试试吧。

Options +FollowSymlinks 
Options -Indexes 

<FilesMatch "\.(tpl|ini|log)"> 
Order deny,allow 
Deny from all 
</FilesMatch> 
RewriteEngine on 



RewriteBase /example/ 



RewriteCond %{HTTP_HOST} ^example\.com$ 
RewriteRule ^(.*) index.php/$1 [R=301] 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^?]*)/([^?]*) index.php?_cmd_=$1/$2 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^?]*) index.php?_cmd_=$1 [L,QSA] 
0

的.htaccess

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

打开的config.php并做以下代替了笨

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

的.htaccess:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

而且在config.php:

变化:

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

到:

$config['index_page'] = ""; 
0

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

+0

欢迎来到Stack Overflow!虽然这段代码可以解决这个问题,[包括解释](// meta.stackexchange。com/questions/114762/explain-completely-code-based-answers)确实有助于提高帖子的质量。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性注释来挤占代码,这会降低代码和解释的可读性! –

0

尝试添加这在.htacces文件:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L,QSA] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC] 
RewriteRule^%1 [R=301,L]