skip to Main Content

I want to remove the seo/ folder name and the file extension(.html) from the below url. I am working on a static html website.

www.example.com/seo/advanced-system.html to www.example.com/advanced-system/

In .htaccess of my root folder I have written this,

RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^seo/(.*)$ www.example.com/$1 [L,R=301]

In .htaccess of my subfolder I have written this,

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

I googled and tried all possible ways, but not able to find the solution. Please help me.

2

Answers


  1. In .htaccess of my root folder, use this

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

    In .htaccess of /seo/, use this:

    RewriteEngine On
    RewriteBase /seo/
    
    RewriteCond %{DOCUMENT_ROOT}/seo/$1.html -f [NC]
    RewriteRule ^(.+?)/?$ $1.html [L]
    
    Login or Signup to reply.
  2. Try this

            RewriteEngine On 
            RewriteRule ^$ seo/ 
            RewriteCond %{REQUEST_FILENAME} !-f 
            RewriteCond %{REQUEST_FILENAME} !-d 
            RewriteRule ^(.*)$ seo/$1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search