Forums

Changing the post preview link (6 posts)

  1. sitehatchery
    Member
    Posted 2 years ago #

    I need to change the preview link. Right now, it looks like this:
    http://web_site.com/?p=2293&preview=true

    It needs to look like this:
    http://web_site.com/index.php?p=2293&preview=true

    I'm surprised that WordPress has index.php for everything else, but not this. This is important because the actual home page has a .html extension and the site pages point to index.php. So, when I hit the preview link, it just displays the index page with the .html extension.

    I've looked into adding a hook for preview_post_link, but I don't know how to do this. With extensive searches on Google, I've come short of an answer. I want to do this in a way that's not a hack and where the changes won't be overwritten with subsequent updates.

    I've looked into ways of doing this with .htaccess url rewriting, but after a couple of hours working at it, I can't figure this one out. Any help would be greatly appreciated. Thanks!

  2. Shane G
    Member
    Posted 2 years ago #

    Hi,

    Change the permalink settings as you like and 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

    Now, check with your old and new posts..

    Thanks,

    Shane G.

  3. sitehatchery
    Member
    Posted 2 years ago #

    This is the default .htaccess code for WordPress. This works for everything else, but it's just that preview link which doesn't have index.php at the end of it.

  4. Shane G
    Member
    Posted 2 years ago #

    Hi,

    Default code should be:

    # BEGIN WordPress

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

    And I have provided edit one:

    # 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>

    Check and compare and have a try tro add it..

    Thanks,

    Shane G.

  5. sitehatchery
    Member
    Posted 2 years ago #

    Ok, I've figured this out:

    RewriteCond %{QUERY_STRING} page_id=(.*)&preview=true
    RewriteRule (.*) /index.php?page_id=%1 [R=301,L]

  6. dwcouch
    Member
    Posted 2 years ago #

    Can this be used to fix this issue? Preview Post fails on Reverse Proxy Redirect

Topic Closed

This topic has been closed to new replies.

About this Topic