Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    101
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Need help with modiying htaccess for WordPress links, please?

    I have WordPress installed on my site in a separate directory - www.domain.com/blog. I am having great difficulty finding my posts. (Yes - I did ask on the WP forums here, but I'm not getting any response.)

    I'm trying to understand what it is I'm trying to do by using the mod_rewrite. Well, I *think* know what I want to accomplish - take a "prettified" URL sent to the server either by a hyperlink or manually typed in, and change that into an address request the server will understand so it can pull up the correct post. Yes??

    This process seems to be complicated by the fact that I have WP installed in a directory that is not root. And moreso by the fact that I'd like an "almost pretty" permalink set by a custom link structure. In all of my research about this on WP and other forums, I can't find a simple and direct step-by-step tutorial (or I'd have this whipped by now!) on how to properly set up the rules and conditions to get this done.

    So, I have questions:

    (1) Without any custom permalink structure set, WP says my post should be at http://domain.com/index.htm/?p=49. So the /blog/ directory isn't even getting included. I tried putting it both between domain and index and between index and /? and neither option worked. Where should it go? What is the address the server is looking for?

    (2) Do I want to modify the htaccess in the root directory or the /blog/ directory? Or does it matter as long as I set the RewriteBase properly?

    (3) From what I read, RewriteBase sets the starting point for the code. That is, anything produced by the processed RewriteRule is appended to the RewriteBase. Is this correct? And root is assumed, so a directory off of root needs to be specified:
    RewriteBase /blog/
    will cause the processed result to be appended to domain.com/blog/ - yes?

    (4) The htaccess mod that WP gave me contained two conditions:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    If I read this correctly, it's saying that the code will be processed to rewite the input URL only if what was input is not already a valid filename - yes? Because if it's already valid, there's no need to rewrite, yah?

    (5) It also contained a rule just before the conditions (from what I understand, this is new with update 3.0??):
    RewriteRule ^index\.php$ - [L]
    If I read this correctly, it's saying if the input URL contains "index.php", change that string to a hyphen??

    (6) My preferred custom permalink structure is "this-post-name-post_id".
    -- That would give me a hyperlink in an email (for example) of domain.com/blog/this-post-name-ID#" - yes?
    -- For WP to find this post on the server, though, it's got to go through the rewrite to get "domain.com/blog/?p=ID#"
    -- My rule then needs to capture the input string, get the ID# from the end and ignore the rest, and then append that ID# to the "?p=" structure - yes?
    -- Assuming the only numbers in my "pretty name" are the post ID numbers at the end, I think my REGEX should look like so:
    ^([A-Za-z-]+)([0-9]+)$ ?p=$2
    Is this correct?

    Here's an actual link that doesn't work to describe what I'm looking at:
    http://familyfunmagic.com/index.htm/...troduction-49/

    Any and all help on this is so greatly appreciated!!
    Ed

  • #2
    Regular Coder
    Join Date
    Jan 2010
    Posts
    101
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Oh - another question:
    Is there any way to echo out what is going in through this process so I can see what's happening?

    Thanks!
    Ed

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    88
    Thanks
    4
    Thanked 26 Times in 26 Posts
    Hi EdNerd,

    A handful of questions which will get an answer in due course - before that (and you've pretty much covered this) a step back to basics and to add clarity:

    If you navigate to http://family********.com/blog/ it works as expected, but the 'recently published' link on the page points to a non-existent location/url: http://family********.com/index.htm/?p=49 Even changing that by hand to: http://family********.com/blog/index.htm/?p=49 it's no cigar.

    Before you can get mod_rewrite to do anything useful that Wordpress install needs some troubleshooting and repair so it honours your subdirectory of /blog/. As you've worked out even if we could get a match on an incoming request, with no working target to send it to we are pretty much stuffed. So find and fix that problem first before getting hung up on mod_rewrite.

    Regarding seeing what MOD_REWRITE is doing/matching; it's perfectly possible with a caveat - rewrite logging needs to be enabled in Apache. Now if you have a dedicated server or VPS that's trivial. You'd add something like this:

    Code:
    RewriteLogLevel 3
    RewriteLog /var/log/apache2/rewrite.log
    To the logging section of your Apache config/Vhost config.

    If you are on a standard hosting plan with a provider things may be tougher. They may offer rewrite logging (ask them if they can enable it for you), or you may have to just put up with flying blind and rely on the help of others - unless you want to set up your own test server.

    If you can square up your Wordpress install and post back, I'll do anything I can to help you out, and I'm sure the plethora of posters here with much better skills than I possess will also do the same.

  • #4
    Regular Coder
    Join Date
    Jan 2010
    Posts
    101
    Thanks
    8
    Thanked 0 Times in 0 Posts
    After a long consultation with a WordPress guru, the general consensus was - I hosed it!! Delete and reinstall - now it all works fine! I set the permalinksin the control panel and it automatically took care of everything. Guess I should have asked when it wouldn't automatically write the the htaccess before I went mucking about, eh??

    So I guess the specific reason for this post is resolved. Thanks for your input. Although in my searching I came across some pretty involved RewriteRules - it looked like it could be fun to get into! Especially since no one else seemed to be able to work thorugh what WP was doing or not doing - because the program handles everything so automatically. So how do you troubleshoot it when it chokes? Can't go delete/reinstall evey time can you?? That would be too much like Windows! :8>O

    Ed

  • #5
    New Coder
    Join Date
    Nov 2011
    Posts
    88
    Thanks
    4
    Thanked 26 Times in 26 Posts
    Not so sure I'd call it 'fun' Ed, I'm no sadist!

    Glad you got it resolved, Happy New Year


  •  

    Posting Permissions

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