Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing subfolders from links with htaccess #302

Open
nlile opened this issue Jan 11, 2017 · 3 comments
Open

Removing subfolders from links with htaccess #302

nlile opened this issue Jan 11, 2017 · 3 comments

Comments

@nlile
Copy link

nlile commented Jan 11, 2017

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
Copy link
Contributor

kicken commented Jan 11, 2017

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
Copy link
Author

nlile commented Jan 11, 2017

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
Copy link
Author

nlile commented Jan 12, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants