首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >codeigniter htaccess 301

codeigniter htaccess 301
EN

Stack Overflow用户
提问于 2013-03-13 16:28:06
回答 1查看 705关注 0票数 0

大家好,我有一个正常的htaccess文件的codeigniter,我想301一个网址到另一个

我不得不混淆链接才能发布:(

即h2tp://www域com/controller/method/value1 ->h2tp://www域com/controller/method/value2

但我正经历着一段地狱般的时光...

这是htaccess

代码语言:javascript
复制
    <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]

如果我把

代码语言:javascript
复制
    Redirect 301 /controller/method/value1 h2tp://www domain com/controller/method/value2 

我明白了

H2tp://WWW域com/controller/method/value2?controller/method/value1

我已经在这上面花了几个小时了,这简直要了我的命:)

EN

回答 1

Stack Overflow用户

发布于 2013-03-15 00:20:45

由于我完全缺乏关于htaccess的知识,我试图在这些行下面添加301重定向。

代码语言:javascript
复制
    #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重定向时,它起作用了。

代码语言:javascript
复制
    #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]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15380233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档