Forums

[resolved] htaccess not needed for permalinks (24 posts)

  1. rhys
    Member
    Posted 2 years ago #

    Is htaccess (with mod_rewrite) not needed for permalinks anymore??

    I notive that one blog I have (2.8.6) works fine without the usual mod-rewrite code in htccess. Switch it it to default, and it works, switch it back to permalinks (/index.php/%category%/%postname%/) and it still works fine.

    WP used to show the htaccess rewrite code at the foot of the page after setting permalinks, but that doesn't show either anymore!

    Can anyone confirm this behaviour?

    This will be magic if we don't need to bother with mod_rewrite anymore to run 'pretty' permalinks.

  2. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    /index.php/%category%/%postname%/ is not a mod_rewrite format. If you have something like MultiViews enabled, the server will recognize index.php as the destination.

  3. seoyourblog
    Member
    Posted 2 years ago #

    I wonder why you need index.php there? remove it.. use just
    /%category%/%postname%/

  4. rhys
    Member
    Posted 2 years ago #

    @SEOYourBlog
    Bad advice! Because I have had several blogs lately that will not work with pretty permalinks starting with /%category%/.

    Google for "Starting Permalinks with %category% is strongly not recommended for performance reasons" to see one reason why.

    @miqrogroove
    I am talking about a plain standard WP default blog, on a plain standard Apache server, not using anything esoteric like Multiview, or any plugins/widgets other than Akismet.

  5. vangrog
    Member
    Posted 2 years ago #

    Actually it's necessary. To use pretty links, WP will create an entry on your .htaccess file (or create a new one if you dont have it yet on your root), pretty much like:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    If WP for some reason cant do it, you need to do it yourself manually, otherwise no pretty links...

    Are you sure there's not such entry on the .htaccess file on your blog root? In my experiences, things don't go fine without it.

    cheers

    p.s.: yes, for some hosts it's necessary to add "/index.php/" on the formula...

  6. vangrog
    Member
    Posted 2 years ago #

    Maybe because of using /index.php/ in the formula, mod_rewrite is not necessary to make things run. I guess that's what Miqrogroove meant. I wasn't aware of that.

  7. rhys
    Member
    Posted 2 years ago #

    @vangrog

    You said:"actually it's necessary. To use pretty links, WP will create an entry on your .htaccess file (or create a new one if you dont have it yet on your root), pretty"

    Actually it is not necessary, on these 2.8.6 installs, it is working fine without it amd there is no sign of htaccess being created. On my older blogs, every time I set up permalinks, it showed suggested new code for htaccess.

    It looks to me like there is now some provision built in for Pretty Links that doesn't need the mod_reWrite in htaccess.

  8. Shane G.
    Member
    Posted 2 years ago #

    Hi,

    Set your desired permalink add this code in htaccess:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    ErrorDocument 404 /index.php?error=404
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Thanks,

    Shane G.

  9. vangrog
    Member
    Posted 2 years ago #

    Rhys, .htaccess is necessary to set pretty links, and not necessary to use almost pretty links (the ones you're using are called "almost pretty", because of the "/index.php" part). That's my guess, according to what I know and what Miqrogroove explained (also, Miqrogroove is an expert; considering what I've read, written by her on this forum, I can say she knows alot -- so, I believe what she says).

    If you use a pretty link structure, such as "%pots_id%/%postname%/" (without "index.php" in the beginning), things will only work with mod_rewrite set on your .htaccess.

    Cheers

  10. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    Which reminds me, I need to update my profile to explain the gravatar I'm using... >_>

  11. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    rhys is correct actually.

    /index.php/%category%/%postname%/

    ... works with standard PHP library when path checking is not enbaled (off by default in Apache, on by default in IIS). I was thinking of the MultiViews format...

    /index/%category%/%postname%/

    ... the latter being considered "correct" so that the URLs aren't all broken if WordPress stops using PHP. Why rhys can't just use proper date permalinks to enable unhindered category management is a matter of personal preference I guess.

  12. rhys
    Member
    Posted 2 years ago #

    @miqrogroove

    Thanks for the explanation, I had several blogs break when I updated them to 2.8.6, but they worked again when I included the /index.php/.

    Still don't understand why my latest blog version makes no attempt to write/update htaccess??

    As to why I don't use the "ugly" proper(?) date format links, I set up "top 10" blogs that rank very well for the site keyword, and to pull off that trick I need proper keyword linking in the URLs and anchor texts
    :-D - Rhys

  13. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    It's starting to sound like a file permissions issue. Make sure the index.php directory and the .htaccess file are both writable.

    I don't know off the top of my head what triggers the .htaccess updates. I prefer it not to happen at all because previous versions of WordPress have made invalid changes leading to the "white screen of death".

  14. rhys
    Member
    Posted 2 years ago #

    @miqrogroove -

    Looks like your theory about index.php is the one. I've set up a test site WordPress Test Site and tried all the listed Permalink combinations, and they all work happily WITHOUT htaccess/mod_reWrite, provided there is index.php preceeding the permalink.

    This applies to 2.9.0 as well (Upgraded and tried it) and it still makes no attempt to upgrade/write htaccess.

    P.S., and please update your profile miqrogroove - it does absolutely NOTHING for your credibility to have an icon that suggests you are a 17 year old sex-kitten????

    ;-) - thanks, Rhys.

  15. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    She's 22, and my profile is updated. ;)

  16. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    It looks like WordPress is supposed to update .htaccess every time you change the permalink settings. So I think it is very likely a file or directory permissions issue preventing it from happening.

  17. rhys
    Member
    Posted 2 years ago #

    So I think it is very likely a file or directory permissions issue preventing it from happening.

    The directory permissions are set to 755 by default, and the trial htaccess file I loaded is the same so I don't see how permissions can be affecting the issue. Just tried all this on an older 2.8.4 blog with identical results.

  18. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    Is there still an issue with .htaccess generation, or is this all resolved now?

  19. henkholland
    Member
    Posted 2 years ago #

    2.8.6 produces a htaccess file and warns when it cannot update automatically and proposes to add the code manually!

  20. rhys
    Member
    Posted 2 years ago #

    @henkholland

    2.8.6 produces a htaccess file and warns when it cannot update automatically and proposes to add the code manually!

    Half the reason for writing this post was because that didn't happen!

    @miqrogroove
    Still no sign of htaccess updating, I've experimented with every value of CHMOD (600 thru 777) and as the Codex suggests, I have FollowSymlinks on plus allowing AddHandler mod-rewrite as in"

    Options +FollowSymlinks
    RewriteEngine on
    AddHandler mod-rewrite allow
  21. Robert Chapin (miqrogroove)
    Member
    Posted 2 years ago #

    ...and you tried the other permalink settings?

  22. rhys
    Member
    Posted 2 years ago #

    I think I can label this post resolved - well as resolved as it's going to get!

    Part one of my question, as to whether htaccess mod_rewrite is not needed anymore is answered by this: Pretty permalinks work fine without htacess/mod_rewrite provided there is /index.php/ in front of the permalink. See PATHINFO "Almost Pretty"

    However, I'm still no wiser as to why the update htaccess mod-reWrite function won't work on any blog on my server. I have tried averything for Automatically Updating HTACCESS and also Fixing HTACESS Generation Issues - see my post directly above.

    @BTW miqrogroove - Your gravatar is now much more 'credible' for a WP Guru!

  23. vangrog
    Member
    Posted 2 years ago #

    lol, this is just what i said b4.. ;-p

  24. kubanek
    Member
    Posted 1 year ago #

    Thanks for the tip ("almost pretty links") guys!
    It's pretty cool having them on hosts like T-Online where .htaccess/mod_rewrite isn't actually available for some (security?) reasons.

Topic Closed

This topic has been closed to new replies.

About this Topic