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

    It needs to look like this:
    https://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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter sitehatchery

    (@sitehatchery)

    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.

    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.

    Thread Starter sitehatchery

    (@sitehatchery)

    Ok, I’ve figured this out:

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

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing the post preview link’ is closed to new replies.