What kind of htaccess rules would i need to accomodate files within folders?

I’m rewriting my portfolio website urls by using the following code in a htaccess file,

RewriteEngine On
RewriteBase /

#remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET (.*).php HTTP
RewriteRule (.*).php$ $1 [R=301]

# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1.php [L]

It all works until I want to navigate to another page from the blog-post.php page
for example, let say I want to go to the about page the url becomes cgarcia.design/web/about and it should be cgarcia.design/about so the page can load properly. Now what would I need to change in the htaccess file to accommodate files within folders?

my nav structure is the following

  • work
  • about
  • resume
  • blog – posts folder – entry
  • contact

Thank you for any suggestions.

Source: .htaccess

Leave a Reply