Support » Fixing WordPress » Preview draft not working with different Site Address URL

  • Hi there,

    Since this topic: is closed for some reason, I will continue here since this problem is far from solved!

    Basically, the generated preview url for drafts uses the site address url and not the wordpress address url and is therefore not working and giving a 404 error page.

    My url setup:
    – WordPress is installed in a root subfolder called ‘blog’ on my main domain A.
    – I have a second domain name B that points to my main domain A.
    – In my General Settings ‘WordPress Address (URL)’ has the following value:
    – In my General Settings ‘Site Address (URL)’ has the following value:
    – I use a .htaccess file in my root to rewrite the url like this:

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/blog/.*$
    RewriteRule ^(.*)$ /blog/$1

    All of the above works perfectly! Except for one little thing; previewing draft posts…
    The generated url when clicking ‘preview draft’ is as follows:
    which results in a 404 ‘page not found’ error page.

    When I manually change the url address into:
    The draft preview shows up perfectly!

    I can’t expect from all the users of my website to manually change this address all the time, so I was wundering if there is a solution for this any time soon?

    I read this article about manually rewriting the preview url:
    Rewrite wordpress preview URL using .htaccess
    but that’s only useful if the generated preview url allready consists of the WordPress Address URL and not the Site Address URL.

    Does anyone have a fix or workaround for this annoying problem?
    Any help is appreciated!


Viewing 8 replies - 1 through 8 (of 8 total)
  • So am I really the only person with this problem?
    I can’t imagine I’m the only one using this setup with 2 domains?

    I found this guide to rewrite the preview URL to a different (sub) domain, but I can’t seem to get it working for my setup:
    How do you redirect URLs with a query string to another host?

    This is part of my .htaccess file in the root of domain-a:

    RewriteCond %{HTTP_HOST} [NC]
    RewriteCond %{QUERY_STRING} ^(p=([0-9]+)&preview=true)
    RewriteRule ^$[0-9]+ [R=301,L]

    Any idea why this isn’t working?

    Thanks to this post from Florian d’Erfurth I found a solution for this problem!

    Add these lines in your .htaccess file in the root of your wordpress installation folder (in this case in the folder ‘blog’):

    RewriteCond %{HTTP_HOST} [NC]
    RewriteCond %{QUERY_STRING} (preview=true)
    RewriteRule ^${QUERY_STRING} [R=301,L]

    And the generated draft preview url will be rewritten to the correct and working url!

    This has been very helpful and works great for previewing drafts under these conditions, but previewing Published posts still yields the error message “You do not have permission to preview drafts.” Any idea why this would work for drafts and not published articles, and how I might alter the rule to apply to both?


    I think because the published preview drafts have 2 more query vars in the url. Example:

    Somehow the rewrite rule should ALWAYS be applied when there’s a preview=true in the url, now it’s only applied when it’s just that one query var.

    I’m no mod_rewrite expert, but there should be some sort of wildcard after the QUERY_STRING line:
    RewriteCond %{QUERY_STRING} (preview=true^)

    I tried these 2 lines, but the error still comes up on the published previews. The draft preview rewrite still works though…

    RewriteCond %{QUERY_STRING} (^|&)preview=true(&|$)
    RewriteCond %{QUERY_STRING} ^(.*)preview=true(.*)$

    Hi, I’m new to wordpress and have encountered a problem which is similar to yours, though only one domain is involved. I couldn’t follow what you were saying about the .htaccess file/coding, but I think you can help me.

    Basically, my URL is
    I set up my blog in a subfolder
    When I go into General settings and make the Site URL point to, my preview mode for any posts no longer works, and instead simply takes me to

    Can you recommend how I can fix this?


    As per the Forum Welcome, please post your own topic. Your problem – despite any similarity in symptoms – is likely to be completely different.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Preview draft not working with different Site Address URL’ is closed to new replies.