user14591460
user14591460

Reputation: 9

Clean URL's within subdirectories

After looking a lot into stackoverflow i'm not able to figure it out. I have a website with the following structure

index.php
contact.php
about.html
forum(dir)
   - index.php
   - thread.php

What i want my htaccess to do

I'm not sure how to figure it out. I was able to remove the extensions but failed in the / "forward slash" part

This is my .htaccess part

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

Upvotes: 0

Views: 130

Answers (2)

Suman
Suman

Reputation: 128

try this demo mod_rewrite link

Upvotes: 0

Shantun Parmar
Shantun Parmar

Reputation: 429

Try below code to remove php extention , same for html you can added

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^forum/thread/(.+) /forum/thread?id=$1 [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

Upvotes: 0

Related Questions