Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End What kind of htaccess rules would i need to accomodate files within folders?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #204140
    cgarcia2595
    Participant

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

    htaccess

    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.

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.