404 Page | Wordpress | Rewrite

Discussion in 'MySQL' started by furca, May 6, 2010.

  1. #1
    Hi,

    I want to make my wordpress blog so that when someone types in..

    mysite.com/name-change/ and it results in a 404. it takes "name-change" and converts it to "name change" and then searches the database for "name change" in the BLOG TITLE field and finds it and sees the page_id is "58" and displays "mysite.com/index.php?page_id=58" while still on the mysite.com/name-change/ page.

    Any ideas on how to do it?
     
    furca, May 6, 2010 IP
  2. aku345

    aku345 Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change the permalink in wordpress setting

    and add this to .htaccess in root directory of your wordpress

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

    # END WordPress
     
    aku345, May 6, 2010 IP
  3. furca

    furca Well-Known Member

    Messages:
    1,478
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Hi,

    I have too many pages so this is causing timeout errors. What you listed is sort of "Default" for wordpress. I need to be done what I listed in the initial post.

    Thanks for trying though.
     
    furca, May 7, 2010 IP
  4. Namjies

    Namjies Peon

    Messages:
    315
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Then you'd need some scripting.

    ~~~~~~~~~~~~~~~~~~~~~~

    a rewrite rule which change
    mysite.com/name-change/
    to
    mysite.com/index.php?title=name-change

    ~~~~~~~~~~~~~~~~~~~~~~

    a new script for index.php which remove dashes and make a search instead of loading the content for an ID (and if there's no result returned, an alternative redirect to a "notfound" page)

    ~~~~~~~~~~~~~~~~~~~~~~

    some modding so every place there is a link shown, it reformats the link to this new format.

    ~~~~~~~~~~~~~~~~~~~~~~

    a redirect rule to a not found page for every url using previous format (index.php?page_id=58) so duplicates cannot be accessed. (or view below for redirect to new url)

    ~~~~~~~~~~~~~~~~~~~~~~

    or, since index.php?page_id=58 and similar urls doesn't use the title in it, if you want to redirect all previous urls to the new ones, you'd have to add a redirect rule for this url format
    index.php?page_id=58
    to
    redirect.php?page=58

    and have a script on redirect.php which looks up for title with ID 58, add slashes to it, the return a redirect to mysite.com/the-title/

    ~~~~~~~~~~~~~~~~~~~~~~

    One of those kind of enhancement which would need ALOT of work.
     
    Namjies, May 16, 2010 IP