0

Hi all I have the normal htaccess file for codeigniter and I want to 301 one url to another

I've had to obfuscate the links to be able to post :(

ie h2tp://www domain com/controller/method/value1 ->h2tp://www domain com/controller/method/value2

but I'm having a hell of a time...

Here's the 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]

If I put

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

I get this

h2tp://www domain com/controller/method/value2?controller/method/value1

I've been hours on this now, it's killing me :)

4

1 回答 1

0

Due to my complete lack of knowledge on htaccess I was trying to add the 301 redirects below these lines.

    #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]

All checks had been run by then and the [L] flag was stopping anymore checks being run.

so when I posted a normal 301 redirect above the following lines it worked.

    #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]
于 2013-03-14T16:20:44.900 回答