Forum

Thread tagged as: Question, Configuration, Blog

Blog posts in the root folder

Instead of putting blog posts in a /posts/ folder I want to run them from the root of the site. So:

https://www.domain.com/name-of-blog-post

instead of

https://www.domain.com/posts/name-of-blog-post

I got it working by adjusting this line in the .htaccess folder

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([a-zA-Z0-9-/]+)$ /post.php?s=$1 [L] </IfModule>

and changing the blog post page path to: {postSlug} in the blog settings.

This worked but when I tried to access the Perch Control Panel it wouldn't let me and just reverted to the home-page of the site.

Any ideas on how to make this work?

Andrew Areoff

Andrew Areoff 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to exclude the /perch folder because the rule you have for the post rewrite will match it.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/perch 
RewriteRule ^([a-zA-Z0-9-/]+)$ /post.php?s=$1 [L] 
</IfModule>

Works brilliantly! Thanks for that.