2013-03-13 45 views
0

大家好我有一個笨正常htaccess文件,我想301 URL在笨htaccess的301

我不得不混淆的鏈接,能夠發佈:(

即h2tp :// WWW域名COM /控制器/方法/值1 - > h2tp:// WWW域名COM /控制器/方法/值2

,但我有一個時間的地獄......

這裏的htaccess

<IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteBase/

     RewriteRule ^(home(/index)?)/?$/[L,R=301] 
     RewriteRule ^(.*)/index/?$ $1 [L,R=301] 


     #Removes trailing slashes 
     #had to remove ajaxquery search else it fails 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteCond %{REQUEST_URI} !(search/ajaxsearch) 
     RewriteRule ^(.+)/$ $1 [L,R=301] 


     #Rewrite all non-www to www based filenames 
     #should get rid of any canonical issues 
     RewriteCond %{HTTP_HOST} ^domain\.es [NC] 
     RewriteRule ^(.*)$ http://www.domain\.es/$1 [R=301,L] 


     #Removes access to the system folder by users. 
     #Additionally this will allow you to create a System.php controller, 
     #previously this would not have been possible. 
     #'system' can be replaced if you have renamed your system folder. 
     RewriteCond %{REQUEST_URI} ^system.* 
     RewriteRule ^(.*)$ /index.php?/$1 [L] 

     #Checks to see if the user is attempting to access a valid file, 
     #such as an image or css document, if this isn't true it sends the 
     #request to index.php 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule ^(.*)$ index.php?/$1 [L] 



    </IfModule> 

    <IfModule !mod_rewrite.c> 
     # If we don't have mod_rewrite installed, all 404's 
     # can be sent to index.php, and everything works as normal. 
     # Submitted by: ElliotHaughin 

     ErrorDocument 404 /index.php 
    </IfModule>[/code][/quote] 

如果我把

Redirect 301 /controller/method/value1 h2tp://www domain com/controller/method/value2 

我得到這個

h2tp:// WWW域名COM /控制器/方法/值2控制器/方法/值1

我一直小時在這現在,它是殺我:)

+0

任何不使用CI內置路由的理由? – 2013-03-13 11:50:45

+0

我真的需要301這個詞給你嗎? – user2164372 2013-03-14 16:16:29

+0

不,這只是一個內部重定向抱歉。 – 2013-03-14 16:17:36

回答

0

由於我完全缺乏對htaccess的知識,我試圖在這些行下面添加301重定向。

#Checks to see if the user is attempting to access a valid file, 
    #such as an image or css document, if this isn't true it sends the 
    #request to index.php 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 

所有的檢查都已經運行,並且[L]標誌停止運行檢查。

所以當我發佈一個正常的301重定向上面的以下行它的工作。

#Removes access to the system folder by users. 
    #Additionally this will allow you to create a System.php controller, 
    #previously this would not have been possible. 
    #'system' can be replaced if you have renamed your system folder. 
    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L]