SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Wordpress - problem with .htaccess file

    Hey peeps,

    im trying to change the permalink structure in wordpress but im having problems with .htaccess.

    I go into wp settings and channge permalink settings to %postname%. It then tells me to update my .htaccess file -
    i dont see one already there so i take a blank .rtf file, insert the code WP gives me. upload it to the root of the wp installation and change its name to .htaccess.

    from everything ive read thats all i should need to do.
    problem is, when i do this, the site does not work at all. i cant even refresh the page without getting an error.

    what am i doing wrong?

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    That's a bit bizarre.
    When you update your permalink structure, WP should normally create and/or modify the .htaccess file in the root of your WP installation.

    If WP can't update your .htaccess file automatically, it will tell you something like "If your .htaccess file were writable, we could do this automatically, but it isnt" near the bottom of the Settings → Permalinks panel.
    Do you see this message?

    Other than that, there are quite a lot of factors which could be influencing this.
    Some hosts (e.g. Godaddy) may not show or allow you to edit .htaccess if you install WordPress through the Godaddy Hosting Connection installation.

    What is your hosting environment?
    Let us know and I'm sure we can get to the bottom of this.

    Oh, and by the way, maybe the .rtf file is causing WP to choke.
    Try creating a plain .txt file instead and see if that makes a difference.

  3. #3
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, Pullo.

    The hosting is with Managed Way.
    I installed WP manually.
    WP did not create an htaccess file when i installed it - at least not that i could find on the root level of the WP installation.
    if your wondering, the ftp client i use is Transmit. I selected "show hidden files" in the view options, and again did not see an htaccess file. from what ive read WP does not always create one.

    I am getting the message of "If your .htaccess file were writable, we could do this automatically, but it isn’t…" but as i said there is no htaccess file visible. Is there somewhere it would be other than the root level of WP?

    The version of WP is 3.4.1

    the rtf is not causing any problems when it is an rtf. its when i rename it to .htacceess that it causes problems.
    i have also tried this with a txt. same result. as a txt it does nothing, when renamed to .htaccess it causes the site not to work and i get the following message:
    "Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@mysite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/2 Server at porthuronairportshuttle.com Port 80"

    the site is porthuronairportshuttle.com
    Last edited by TechnoBear; Aug 15, 2012 at 09:38. Reason: e-mail address edited

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok then, let's see if this works:
    Create a blank txt file on your desktop.
    Call it 1.htaccess.
    Upload it to the root of your WP install.
    Rename it to .htaccess.
    Set the permissions on the newly-uploaded file to 666.
    Then try changing the permalink structure in your WP back end.
    Any difference?
    FWIW it sounds to me like you are doing everything correctly.

  5. #5
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    followed your instructions precisely.

    Doesnt matter how i do it. Every time a file called .htaccess is in the root of wordpress, the entire site stops functioning. regardless of permissions or if it was originally a plain text or rich text or whatever.

    the minute it is renamed to something else (1.htaccess, htaccess.txt, etc) it is ignored and everything goes back to normal.

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok, that's weird.
    Does even a blank .htaccess file stops WP from working?

    What is your directory structure?
    Is WP in the root of your webspace or a subdirectory?

  7. #7
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WP is at the root of the domain - however there are multiple domains on the ftp.
    so its
    ftp root>domains>domain.com>public_html>here are the wordpress files

    yes even a blank .htaccess file stops the site from working - not just wordpres, THE ENTIRE DOMAIN - even a static html page will not load with a .htaccess file (blank or not).

    there are no other .htaccess files in the domain and as far as i can see none on this ftp whatsoever.

  8. #8
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok.
    Make a .htaccess file as described above and stick this code in it:
    Code:
    Redirect 301 / http://www.sitepoint.com/
    Upload it to your FTP root (i.e. the root of everything) and then try to call up your site in a browser.
    Does that have any effect?

    Also, when doing this try clearing the cache in your browser, or using a different browser from normal.

    I have a similar setup for you and this works for me.
    It's starting to sound that this might be an issue with the hosting company.

    P.S. If it works, don't leave this file on your server as it redirects everything to SitePoint.

  9. #9
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That worked.

    it redirected to sitepoint.
    i have removed it from the ftp root.

  10. #10
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok, at least we know that this functionality is not being blocked by your host.
    What happens if you move it into domain.com?

    What is your WordPress Address and your Site Address set to in your WP backend?

  11. #11
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the redirect works from the domain root (domain.com folder)

    and as far as wp address and site address in wp backend - im not clear on what you are talking about here

  12. #12
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by tim@getdim View Post
    and as far as wp address and site address in wp backend - im not clear on what you are talking about here
    On the Settings->General screen in a single site installation of WordPress, there are two fields named "WordPress address (URL)" and "Site address (URL)".They control where WordPress thinks your site is located.

    The "WordPress URL" is the address you want people to type in their browser to reach your WordPress blog.
    The "Site URL" is the address where your WordPress core files reside.

    On my site, for example, my WP URL is http://domain.com, my site URL is http://mysite.com/mywordpressinstall.
    This results (for me at least) in WP dropping a .htaccess file in my 'domain.com' folder, which directs all incoming traffic to the 'mywordpressinstall' folder.

    Silly question: what happens if you drop the .htaccess file into the public_html folder. Does WP still choke?

  13. #13
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    both are pointing to http://porthuronairportshuttle.com which is where the visitors are supposed to go and where the wp files are installed.

    as stated earlier public_html IS where the wordpress files are. putting a blank .htaccess file there chokes the site and putting one there with the redirect, well, redirects as it should (as we already saw).

    maybe i wasnt clear earlier. the WP files are on the root level of public_html, NOT in a subfolder.

  14. #14
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just for fun i tried pointing the redirect to http://porthuronairportshuttle.com - which causes an infinite loop which entertains me slightly.

  15. #15
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Glad you're having fun, as this must actually be quite frustrating
    If it makes you feel any better, I've got WP set up locally on a virtual machine (for testing) and I just killed that by messing about with the .htaccess file.

    Anyway, sorry I misunderstood your folder structure.
    So putting a .htaccess file in your WP root with the redirect to SitePoint works as expected.
    At least now we have a .htaccess file in your WP root which is not being ignored.

    Can you set the file permissions on the .htaccess file to 777 (the max possible), then try and update your permalink structure via the WP backend.
    What does WP say?
    Do you still get the "If your .htaccess file were writable ..." message?

    If not, then can you pull the file back off the server and see what WP has written to it.

  16. #16
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it should be noted that i tried the .htaccess file with the parameters wp generates for you if your .htaccess file is not writable - this also choked the system.

    also another amusing thing:

    when the .htaccess file is a redirect to sitepoint, i try to update the permalink structure (with max permissions) and i discover sitepoint is built with wordpress (i am redirected to sitepoint.com/wp-login.php)

    so i blanked out the .htaccess file and uploaded it again (with max permissions), updated the permalink structure... and it seems to have worked this time. what we did differently i am unsure of.

    i downloaded the file.

    here is what WP wrote to the file:
    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    why did this work? what did we/I do differently? im confused...

  17. #17
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Sorry man, I'm out of ideas.
    It's quite a difficult issue to debug remotely.
    It sounds like you are doing everything correctly, but if you check WP forums, there are actually quite a lot of people having problems with this kind of thing
    E.g. here: http://wordpress.org/support/topic/p...nk-to-postname (I know that's not 100% your issue, but you get the idea).

    If I was you, I would read this: http://codex.wordpress.org/Using_Permalinks and try what they suggest there.
    If that fails, I would contact your hosting company for help.
    They will be in a much better position to help you than me.

    It would also be nice if you post back here if you manage to solve your issue and tell us how you did it.
    Oh, and don't forget to change the permissions back to something sensible on the .htaccess file.

    Sorry I couldn't help you more.

  18. #18
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    read my last post

  19. #19
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok, so you must have edited that while I was replying.
    Does that mean that everything is working and that your permalink structure is now how you wanted it?

  20. #20
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. the site is working perfectly and the permalinks are %postname% as they should be.
    im still trying to figure out what was done differently than before.

    the facts:

    • previous attempts with a blank .htaccess file choked the system.
    • previous attempts with the exact same code, manually entered (minus "# BEGIN WordPress" and "# END WordPress") choked the system.

    speculation:
    • "# END WordPress" is a comment and therefore should not have any effect whatsoever on the file.
    • file permissions at anything higher than "444" should not have that type of effect on the file

    i just noticed, however that the file is now at 644 permissions - i had not changed it yet so im thinking WP changed it automatically.

  21. #21
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Excellent!

    My guess as to why it suddenly worked are two-fold:

    Browsers appear to be able to cache directives in .htaccess files (for the want of a better way of explaining it).
    An example: tonight I uploaded the previously discussed .htaccess file that redirects you to SitePoint to one of my servers. I tested it, it worked (I was redirected), I then deleted the .htaccess file and thought nothing more of it.
    When I entered the site's URL in the browser 20 minutes later (bearing in mind that I'd deleted the .htaccess file from the server before hand) I was still redirected. It was only when I cleared my browsers cache that I could access the site as normal.
    Maybe your browser remembered a failed attempt, then when you tried something that should have worked, it still failed??

    Also, the exact permissions you need to give WordPress, so that it has write access to your .htaccess file depend on your server setup.

    It seems unlikely that the "# BEGIN WordPress" and "# END WordPress" comments should stop this from working.
    AFAIK these are there, so that WP can safely overwrite anything that is between them, but won't touch the rest of your .htaccess file.

    This is just speculation on my part, but at least we got it working in the end.

  22. #22
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,227
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    AFAIK

    # BEGIN WordPress
    # END WordPress

    are not only comments, they serve to let WordPress know where to begin and end writing the generated directives.

    I've never had this problem before but I guessing without them WordPress gets lost and doesn't deal with the situation very nicely.

    Edit:

    more posting while typing

  23. #23
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,999
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by Mittineague View Post
    AFAIK

    # BEGIN WordPress
    # END WordPress

    are not only comments, they serve to let WordPress know where to begin and end writing the generated directives.
    I thought the same thing, but I tried removing them from the .htaccess file on my site and everything still worked as expected.

  24. #24
    SitePoint Zealot tim@getdim's Avatar
    Join Date
    Jul 2012
    Location
    Detroit
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well at least i (should) know what to do next time (for this host anyway)

    Mucho Thanks


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •