2016-08-09 25 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]