Draft preview not working

  • I am able to preview published posts but not drafts. As per the video tutorial on rewrite rules, I have added the following to my .htacess file.

    Code
    1. RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ /blog/post.php?s=$1&preview=all [L]
    2. RewriteRule ^/blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]


    Can anyone suggest how I can fix this please?

  • I'm afraid not.


    When I click on the view draft button I am taken to ...

    domainname/blog/PostTitle/preview

    instead of

    domainname/blog/post.php?s=PostTitle&preview=all


    If I manually type in domainname/blog/post.php?s=PostTitle&preview=all the draft shows properly

  • Is this regular perch or is it runway?


    If you are using runway you'll need to setup a route for the preview URL, and make sure it has priority over your post route.


    If not, can you post your full .htaccess file as there may be something else causing it to fail

  • Been trying all sorts of variations but still no joy. This is what I have in my .htaccess file...


    Code
    1. RewriteEngine On
    2. RewriteCond %{REQUEST_FILENAME}.php -f
    3. RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
    4. RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ blog/post.php?s=$1&preview=all [L]
    5. RewriteRule ^blog/([a-zA-Z0-9-/]+)$ blog/post.php?s=$1 [L]

    I am using perch

  • 1. Check that the server supports Rewriting.


    2. Check this rule, there should be a / before the second blog

    Code
    1. RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ /blog/post.php?s=$1&preview=all [L]


    3. Simplify the .htacess file. Take out all rules except the blog preview rule. Does it work?

    4. Show us the complete .htaccess file

  • The server supports rewriting and I've added a / before the second blog.

    I tried taking out all the rules and still no joy.


    I have the following code in my .htaccess file which is located in the server under public_html


    Code
    1. RewriteEngine On
    2. RewriteCond %{REQUEST_FILENAME}.php -f
    3. RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
    4. RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ /blog/post.php?s=$1&preview=all [L]
    5. RewriteRule ^blog/([a-zA-Z0-9-/]+)$ blog/post.php?s=$1 [L]

    In addition there is another .htaccess file in the level above public_html which has the following data...


    I have tried with this data deleted but it doesn't seem to make any difference

  • The rewrite rule is correct, so there will be something conflicting with it.


    Can you confirm that the RewriteRule ^blog/([a-zA-Z0-9-/]+)$ blog/post.php?s=$1 [L] works fine. Check it works when you change it to something else as well like RewriteRule ^news/([a-zA-Z0-9-/]+)$ blog/post.php?s=$1 [L].


    Check in your blog/ folder for an additional .htaccess, as this will take precedent over the root file