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.

Strange, inconsistent redirect/404 -- .htaccess issue?

November 15, 2011 7:22pm

Subscribe [3]
  • #1 / Nov 15, 2011 7:22pm

    aleklisefski

    24 posts

    I’m using v2.2.2 - Build: date 20110801

    I’m getting a strange redirect/404 issue on one particular page: http://www.bidontravel.com/blog/author/3/—You’ll see when you go to this URL that it removes the “author/3” to result in http://www.bidontravel.com/blog//. If the trailing slash is not added (http://www.bidontravel.com/blog/author/3), it’s truncating to result in http://www.bidontravel.com/blog

    It should behave the same as all other author pages such as: http://www.bidontravel.com/blog/author/2/

    I’m 100% sure this was not happening before, but I don’t know what caused it.

    I recently made one change to .htaccess to force trailing slashes, the code can be seen below. However, I have un-done this and reverted to the old .htaccess without this new addition and it still behaves the same.

    I have triple checked the URL “/author/3” under the page publish settings. It is identical to all my other author pages except for the number 3.

    Why would this happen with only /author/3 and not 2, 5, or 6, I have no idea? Please help!

    Here’s the .htaccess as it is currently:

    <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 ^(.+[^/])$ /blog/$1/ [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 ^(.*)$ /blog/index.php/$1 [L]
    
    </IfModule>
  • #2 / Nov 16, 2011 1:47pm

    Dan Decker

    7338 posts

    Hi aleklisefski,

    I’m sorry you are running up against this, and I’ll do what I can to get you all set.

    Currently, the only supported method for removing index.php via .htaccess is:

    <IfModule mod_rewrite.c>
            RewriteEngine On
    
            # Removes index.php
            RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php/$1 [L]
    
            # If 404s, "No Input File" or every URL returns the same thing
            # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    So that gives us 2 routes to try:
    1) If you take .htaccess out of the picture by renaming for testing purposes, does everything work as expected? Keeping in mind to add “index.php” back to Admin-> General Configuration: Name of your site’s index page
    2) If you replace your current .htaccess with one that contains the supported directives, does everything work as expected?

    Also, can you tell me what the numbers represent? Member IDs, entry IDs?

    Thanks!

  • #3 / Nov 16, 2011 9:05pm

    aleklisefski

    24 posts

    Your example:

    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    My code:

    RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /blog/index.php/$1 [L]

    Except for the addition of css in the list of file types to ignore and the addition of /blog in the rewrite rule to point to the appropriate directory, this is the same method I am using. The code is identical except for these two places.

    I have tried eliminating all other lines of code from my .htaccess and the problem still persists. I have to maintain the index.php removal part of .htaccess as the site is live and I cannot mess with that.

    I’d also like to note that this method of index.php removal has always been working perfectly on this site, and I have always been done using this same .htaccess code.

    The problem was NOT occurring when I set up index.php removal and for some time afterword. The first time I noticed this issue was after adding trailing slashes via .htaccess, which made me think that was the issue. But I have tried removing those lines of code to no effect, so I don’t think it’s that either.

    The URL /author/3 refers to a page URI created using the pages module. “3” is not the URL title, member ID or entry ID, but an assigned URI for that page. All other author pages follow the same format, and as you can see on the site, all other author pages (with numbers 1 - 7) are working as they should.

    This is what I have entered in the Page URI field for the page in question: /author/3

    This format is consistent with all other author pages that are working (/author/1…/author/7)

    By elimination all of the .htaccess code except for the part I know for certain was NOT causing this problem, I’m starting to eliminate .htaccess as the problem. Do you see anything else that could be causing it?

    Even if it was .htaccess, how on Earth could it only affect /author/3 and no other URLs?

     

  • #4 / Nov 17, 2011 1:43am

    Cheif

    626 posts

    Have u tried removing 3 and re-adding it ? Sometimes with weird stuff like this deleting and re-adding the entry seems to fix it.

    Also, it’s not set to “closed” is it ?

  • #5 / Nov 17, 2011 11:04am

    aleklisefski

    24 posts

    Hey Cheif, Thanks for the suggestion. It’s definitely “Open.”

    I tried deleting the page in the Pages module, thus removing the URI. I then reset it to “/author/3” and still have the same problem :( I’m going to also delete the entry entirely and recreate it, though I don’t think that will work either.

  • #6 / Nov 18, 2011 5:01pm

    Dan Decker

    7338 posts

    Hi aleklisefski,

    Is there a chance we could get in and have a look at this? Please be on the lookout for an email from me.

    Thanks!

  • #7 / Nov 18, 2011 5:20pm

    aleklisefski

    24 posts

    Done. EE instal can be found under “blog” directory in web root.

  • #8 / Nov 22, 2011 3:05pm

    Dan Decker

    7338 posts

    Hi aleklisefski,

    This is definitely something to do with .htaccess This URL works: http://www.bidontravel.com/blog//?/author/3/ with the “?” forcing index.php, though hidden, to execute the query. Is there anyway you can schedule some downtime for the site and take .htaccess out of the process and reintroduce index.php ? That will be the only way for us to determine if ExpressionEngine is at fault in anyway.

    Thanks!

  • #9 / Nov 23, 2011 7:18pm

    aleklisefski

    24 posts

    Solved it!

    Turns out it had nothing to do with EE or my .htaccess file.

    I don’t manage the web root, only /blog/ where EE is installed. Apparently someone had set up a 301 redirect in the root directory specifically for /blog/author/3. Don’t ask me why.

    Anyway, thanks for your help!

  • #10 / Nov 27, 2011 9:03am

    Sean C. Smith

    3818 posts

    aleklisefski,

    Glad you resolved this. Am going to close this thread, but feel free to post again as needed.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases