PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
256 stars 48 forks source link

Removing subfolders from links with htaccess #302

Open nlile opened 7 years ago

nlile commented 7 years ago

For organizational purposes, it would be nice to keep all pages in a folder, but I need all my urls to be stripped to just post-name. I've tinkered with the htaccess and can't get mod rewrite to make any changs. Is there a work-around? Or a way to do this that I'm missing?

kicken commented 7 years ago

I don't follow what you're looking to accomplish. Can you explain with an example of the directory and url layout you are trying to accomplish?

nlile commented 7 years ago

Hey @kicken sorry for not being clear. Basically, I want to use a folder, but I don't want it showing up in the URL.

So, all of my posts about blogs are in folder /blog/

example.com/blog/post1 example.com/blog/post2 example.com/blog/post3

I need the URLs to just be

example.com/post1 example.com/post2 example.com/post3

nlile commented 7 years ago

@kicken I've tried adding

   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)/?$ /blog-folder/$1 [NC,L]

and combining

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/?$ blog-folder/index.php [NC,L]

and RewriteRule ^blog-folder/(.*)$ /$1 [L,R=301]

I'm not familiar with the internal system which is probably why I can't figure out the way htaccess rewrites affect the links.