Forum

Thread tagged as: Question, Blog

Clean URLs / mod rewrite

hi,

in the documentation you recommend to add a rule for the draft URLs

You should rewrite it to add the query string argument preview=all to the URL. <

how would i write it ? i can't figure out how the syntax has to be ?

Thanks! katja

Katja Schwarz

Katja Schwarz 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to have preview=all on the URL, e.g.

/blog/post.php?s=my-post-slug&preview=all

i'm sorry, but i don't quite get it:

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

this does not work ...

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need something like:

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

i added this, but it does not work; there is page with a side bar (tags, archive), but the post/article does not show up on th page

the url is : mydomain.de/blog/2014-12-03-test-draft/preview

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where does the rule appear in order? You may need to before the regular post page rule.

<IfModule mod_rewrite.c>  
    RewriteEngine on  
    # rules go here
    RewriteRule ^blog/([a-zA-Z0-9-]+)/preview$ /blog/post.php?s=my-post-slug&preview=all
    RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
</IfModule>

i changed the order, but still, the post is not displayed on the page ...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Try:

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

this works, thank you, the post is shown on the page

i just have to work out now how to adjust the path to the css

thanks again, best regards ! katja

Same problem here, Katja. How did you solve not seeing the css file when '/preview' is suffixed?