ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

problem with .htaccess redirects creating funny URLs with /?/

February 19, 2013 2:56pm

Subscribe [3]
  • #1 / Feb 19, 2013 2:56pm

    aleklisefski

    24 posts

    I’m having a problem where 301 redirects are creating funny URLs with /?/ in them.

    The URLs are showing the correct page, but are a problem because they considered different URLs by google, and so are creating a lot of pages with duplicate content.

    For example, the line:

    Redirect 301 /hygiene/contact.html http://www.cmpsolutions.net/contact

    Should redirect http://www.cmpsolutions.net/hygiene/contact.html to http://www.cmpsolutions.net/contact, but instead I’m getting http://www.cmpsolutions.net/contact/?/hygiene/contact.html/

    I can’t figure out why the original URL segment is being attached to the end after an added “/?/”

    Can someone please help.

    I’m using the following .htaccess rules (not including individual 301 redirects):

    <IfModule mod_rewrite.c>
    
    # Enable Rewrite Engine
    # ------------------------------
    RewriteEngine On
    RewriteBase /
    
    # Add Trailing Slashes to URLs
    # ------------------------------
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+[^/])$ /$1/ [R=301,L]
    
    # Redirect all traffic to www
    # ------------------------------
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ <a href="http://www.%{http_host}/$1">http://www.%{http_host}/$1</a> [R=301,L]
    
    # Redirect index.php Requests
    # ------------------------------
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{THE_REQUEST} !/system/.*
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
    
    # Standard ExpressionEngine Rewrite
    # ------------------------------
    RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    </IfModule>

    One thing to note, which is different than some servers: The last line:

    RewriteRule ^(.*)$ /index.php?/$1 [L] - needs the “index.php?” instead of just “index.php” to work properly on my MediaTemple DV server.

    Does it have something to do with the order in which these rules are executed? I’ve a tried a few different orders and can’t seem to solve it.

     

  • #2 / Feb 21, 2013 5:24pm

    aleklisefski

    24 posts

    Bump. Any ideas here?

  • #3 / Feb 21, 2013 7:36pm

    MDB

    83 posts

    Turn “Force Query Strings” off located at Admin>>System Administration>>Output and Debugging and enter the following in your .htaccess file  
    RewriteRule ^(.*)$ /index.php?/$1 [L]    See if that works

    Some servers require the “Force Query Strings” setting to be turned on to work properly.

     

  • #4 / Feb 22, 2013 1:54pm

    aleklisefski

    24 posts

    Force Query Strings was already turned off and that line already appears in my .htaccess as you can see in my original post. Do you mean turn Force Query Strings on? And then change that .htaccess to something else?

  • #5 / Feb 22, 2013 2:34pm

    aleklisefski

    24 posts

    More info:

    It’s a MediaTemple DV server. Mod_rewrite is obviously enabled. PATH_INFO variable is supported.

    Anyone else on a DV server and have issues with redirects?

  • #6 / Apr 02, 2013 5:46pm

    aleklisefski

    24 posts

    BUMP. Can anyone help with this?

  • #7 / Oct 24, 2013 1:04pm

    I’m experiencing the same problem at the moment too.
    Did you ever figure this one out?

  • #8 / Oct 24, 2013 1:14pm

    aleklisefski

    24 posts

    Never figured it out. Seems no one is able to help. MediaTemple can’t troubleshoot 3rd party software (even though an .htaccess file is hardly third-party software), and Have had no other useful responses on this forum. If you are able to figure anything out, I’d love to hear about it.

  • #9 / Oct 25, 2013 3:28am

    I’m going to try and get a techie guy to look into it… coz otherwise all my 301 Directs don’t work.
    Will let you know if we come up with a solution.  😊

  • #10 / Aug 14, 2014 5:08pm

    So I came across this problem again today, and decided to open a Support Ticket for it. Thankfully the EE Support team came up trumps with a solution….

    Here was my problem today:

    I’ve got my 301 Redirects set up like this:

    Redirect 301 /oldpage.html   <a href="http://www.domainname.co.uk/newpage">http://www.domainname.co.uk/newpage</a>

    So this URL:
    http://www.domainname.co.uk/oldpage.html

    Should Redirect to this one:
    http://www.domainname.co.uk/newpage

    But instead it’s going to this one (although the page content is correct): http://www.domainname.co.uk/newpage?/oldpage.html

    I’ve set this line in the htaccess, otherwise I get an “No input file specified.” error:

    RewriteRule ^(.*)$ /index.php?/$1 [L]


    And this is the solution that Robin from EE Support came up with:

    Hi Oliver.
    That was a tricky one!  It seemed like it should just work but it very obviously did not.

    I pulled Pascal in and he figured it out - he added html to the files not processed through index.php:

    RewriteCond $1 !\.(gif|jpe?g|png|xml|html)

    I am frankly a little confused as to why it was needed- I’d have thought moving the 301’s to the top would have rendered it moot.  But that does seem to be the tweak that was needed to get things working.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases