Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2018
    Posts
    10
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question .htaccess issue: trailing slash added, but not working for subdirectory

    have found a well working .htaccess code on the internet that removed the .html extension and adds a trailing slash at the end of the URL.

    However, when I link to a site in a subdirectory, it does not work, the subdirectory automatically gets erased in the URL, so the page is not loaded.

    Here is my .htaccess code:
    Code:
    AddHandler application/x-httpd-php71 .php
    
    AddDefaultCharset utf-8
    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} example.com [NC]
    RewriteRule (.*)$ http://www.example.com/$1 [L,R=301,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ([/]+)/$ $1.html
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]
    I also have this same .htaccess in said subdirectory.

    Does anybody have an idea how I can fix this issue?
    Thanks for any help!

  2. #2
    New Coder
    Join Date
    Oct 2018
    Posts
    10
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Edit: for clarification I may add that the subdirectory I'm talking about is part of the same website, so some parts of it I would like to keep in a subdirectory just for keeping things organized.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •