• Ok, so I am in the final stages of converting from MT to WP, and I have run into an issue.
    All of my MT individual post pages are in the format “/archives/YYYY/MM/DD/index.php#*postnumber*”
    As there is apparently a problem (or at least I am having one) with WP and my trying to use “index.php” at the end of an archive listing, I am looking to try to use a .htaccess directive to redirect people to go to the site via a google link, for example.
    I’d like to have it so that anyone who enters:
    “/archives/YYYY/MM/DD/index.php#*postnumber*”
    will be redirected to:
    “/archives/YYYY/MM/DD/”
    or more simply, anyone who directly references a “index.php” file would get redirected to the same path sans the php reference at the end:
    “/archives/YYYY/index.php” –> “/archives/YYYY/”
    “/archives/YYYY/MM/index.php” –> “/archives/YYYY/MM/”
    etc.
    anyone know the best way to accomplish this? I am still in the process of figuring out how the .htaccess format works, and would appreciate any help anyone can give.
    thanks in advance,
    -Chris

Viewing 9 replies - 1 through 9 (of 9 total)
  • All of my wp individual post pages are in the format “/archives/YYYY/MM/DD/index.php#*postnumber*”
    did you mean:
    All of my MT individual post pages are in the format “/archives/YYYY/MM/DD/index.php#*postnumber*”
    ?

    Thread Starter ckelly5

    (@ckelly5)

    heh, yeah. oops. my bad. fixing now

    Ok, I thought so but just be sure..
    If I understand you right you want people who follow your old links (google, bookmarks) to land on the right new pages and have the new links written out in their browser. In that case you want to use a permanent external redirect (permanent to tell google to update its links and external to show the user that the link has changed) .
    This external redirect would take the old names and translate them to the new ones which in their turn will be translated by the internal (for user invisable, by wordpress generated) redirect to get the sql string.
    And now you want me to give you these external rewrite rules… mmm

    Thread Starter ckelly5

    (@ckelly5)

    yeah, pretty much. I could be a jerk and redirect all the 404s to the main index, but I thought I’d try and be a nice guy and send them to the right page… ??

    yep
    I don’t really know + I’m going to the movies right now (it’s 22.15 here in Spain)
    to get you started:
    https://www.sitepoint.com/article/guide-url-rewriting/1
    https://httpd.apache.org/docs-2.0/mod/mod_rewrite.html
    https://www.engelschall.com/pw/apache/rewriteguide/
    the redirect rules should be flagged with:
    [R=permanent]
    Sorry for the minor help at this point in time.

    wish i could help – i’m trying to learn the mod_rewrite thing for myself… ??

    Thread Starter ckelly5

    (@ckelly5)

    well I kinda cheated on this one. My original MT journal was in the main directory of my site at https://www.ckelly.net/. I was planning originally on moving everything to a “/journal” subdirectory where all the new WP stuff would stay. When I was writing these requests, I was toying with the idea of putting everything back in the main root dir, but after the headaches this seemed to be causing, I decided to just go ahead and put in all in the “journal” subdir after all. When I decided to do that, the .htaccess file portion of things was easy.
    thanks for you help thomasmaas

    You’re welcome Chris. Please consider posting your complete & final solution in this thread to make it more usefull for other people with similar problems. It would be so nice if problem related threads would go like:

    1. problem
    2. discussion (clarification of problem, possible solutions)
    3. final solution
    Thread Starter ckelly5

    (@ckelly5)

    apologies for the dealy on this one…
    the problem, in a nutshell was that I was converting from MT to WP. My original journal was in the root directory of my site https://www.ckelly.net. I was planning on just putting the new stuff in a subdirectory called “journal”, but toyed with the idea of putting everything in the same place as the previous journal (in the root dir). I didn’t want any search engine hits to become 404s, so I looked to .htaccess files for a solution.
    my idea involving .htaccess was to have all my search engine results for my archives properly redirect to the new format. My original MT archive format was “/archives/YYYY/MM/DD/index.php#*postnumber*”. When I tried to get the WP formatting to match up to this, i encountered complications with the fact that the main page for WP is also index.php. so i was simply trying to redirect any URL that ended in “index.php” to redirect to that URL, sans the file specifier on the end (“/archives/YYYY/MM/DD/index.php#*postnumber*” becomes “/archives/YYYY/MM/DD/”). This turned out to be very difficult, as even referencing a directory it would try and load the index.php, and the rewrite rules would kick in and make a redirect loop.
    my solution was to go back to my original idea and place the WP files in a “/journal” directory, and redirect from there. rewrite rules then became:
    if it’s the root directory (main page only, pretty much), then redirect to that dir with a “/journal” at the end of the main URL and before any subdirs. This takes care of anyone going to the main url. they are redirected to the journal subdir.
    if it is in the archives directory at all “/archives”, then modify the path to strip off the “index.php and anything after it, and redirect it to the “/journal/archives” directory with the same date formatting after. (e.g. “/archives/YYYY/MM/DD/index.php#*postnumber*” becomes “journal/archives/YYYY/MM/DD/”. This takes care of the archives and incoming search engine links. The new archives pages use the topic name as the file URL (e.g. the post “new engine” becomes ckelly.net/journal/archives/*date*/new-engine, but the content will still show under ckelly.net/journal/archives/*date*/
    all in all it works pretty well, and I am happy with the results. if anyone would like a copy of the .htaccess files, I’d be more than happy to help out.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘.htaccess redirection question’ is closed to new replies.