WordPress.org

Forums

.htaccess file (12 posts)

  1. asphodel
    Member
    Posted 11 years ago #

    I'm trying to get permalinks to work, but I'm not at all familiar with the .htaccess/mod_rewrite. When I downloaded WordPress, example.htaccess was included. Is that file supposed to be renamed to something in particular? Also, in the Options section of the WordPress panel, it says "For this to work you'll need mod_rewrite installed on your server "...what's that?

  2. Cena
    Member
    Posted 11 years ago #

    Mod_rewrite is a module for the Apache web server tha, among other things, allows for things like rewriting long, cumbersome, Google unfriendly URLS like http://yoursite.com/?m=3421 into something like http://yoursite.com/my-first-post.
    Basically, to use the code generated in the permalinks option page, copy it, and open up your text editor. Paste it in a new document, then save the document as '.htaccess'. This needs to go in your root WP directory (the directory that contains all your WP files and folders.) Simple as that, assuming your server has mod_rewrite installed.
    If it works, then it does. If it doesn't, there could be other problems, but the first thing to check is your hosting company, to see if they do in fact have it installed.

  3. asphodel
    Member
    Posted 11 years ago #

    Is the .htaccess file supposed to "disappear" from the FTP after you rename it (from example.htaccess to .htaccess)? Does it matter that I'm using a subdomain?

  4. NuclearMoose
    Member
    Posted 11 years ago #

    asphodel,
    Yes, the file will not show up on your FTP client. You would have to work directly on your web server to see it show up.

  5. Alex King
    Member
    Posted 11 years ago #

    Often there is a setting in the FTP client to hide/show the '.ht...' files.

  6. OperaManiac
    Member
    Posted 11 years ago #

    AceFTP does not show it, while SmartFTP shows it!
    These are the 2 software I use for my FTP requirement...

  7. Alex King
    Member
    Posted 11 years ago #

    I highly recommend FileZilla on windows.

  8. asphodel
    Member
    Posted 11 years ago #

    Thanks everyone. How do the permalinks work, though? The permalinks work now, but the actual files aren't in the ftp, yet they "magically appear" (for lack of a better term). I don't think they're hidden, either, because the entire archive folder (for me, it's /past) is nonexistent.

  9. antifuse
    Member
    Posted 11 years ago #

    @asphodel: The way it works is this - when you put those lines into the .htaccess file, it tells Apache (the web server software) to look for any requests for http://www.yoursite.com/past/day/posttitle (or whatever you decided on for your format) and to re-interpret them to ACTUALLY load the page http://www.yoursite.com/index.php?date=blah&post-title=blah (or whatever the actual formatting is, I'm just paraphrasing here).
    The mod_rewrite library is quite a powerful tool... if you ever do something like change your archive formatting (something I have done several times in the past) or change your content management system, you can just add in a re-write rule and all of your old links (if you've been indexed by google, as an example) will still work.

  10. NuclearMoose
    Member
    Posted 11 years ago #

    Quick question about the .htaccess file -- was there not an example.htaccess included in past versions of WP? The nightly build doesn't have this, nor does the Platinum release. Or am I just imagining things?
    Craig.

  11. antifuse
    Member
    Posted 11 years ago #

    I don't recall seeing one... but then I've got my own .htaccess already so maybe I deleted it and just blocked my memory of doing so :P

  12. Cena
    Member
    Posted 11 years ago #

    No, there was an example.htaccess, but if I recall correctly, it contained other rules besides rewriting the urls. Ah..found it..take a look if you're curious about what it contained. (From a copy of the 12.24.03 CVS):
    # this will make register globals off in b2's directory
    # just put a '#' sign before these three lines if you don't want that
    <IfModule mod_php4.c>
    php_flag register_globals off
    </IfModule>
    # this will set the error_reporting level to remove 'Notices'
    <IfModule mod_php4.c>
    php_value error_reporting 247
    </IfModule>
    # This activates content negotiation, so instead of /archives.php you could just call
    # a file as /archives . Same for any other file on your site. Try it out!
    Options +Multiviews

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.