views:

34

answers:

1

This is beyond my level and I need some help.

In the htaccess make redirect rules for the following...

  1. if example.com/1stleveldirectory doesn't end in a slash add one.
  2. if example.com/1stleveldirectory/ ends in a slash don't add anything.
  3. if example.com/1stleveldirectory/file is like this add .html.
  4. if example.com/1stleveldirectory/file.html is like this don't add anything.

There are no publicly accessible directories past the first level

Thanks!

EDIT: I should have said I already have this code at the top of the file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Options +FollowSymLinks
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?cat=$1&name=$2 [L]
RewriteRule ^([^/]*)/$ /index.php?cat=$1 [L]
A: 

Try these rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/]+$ %{REQUEST_URI}/ [L,R=301]
RewriteCond $0 !.+\.html$
RewriteRule ^[^/]+/[^/]+$ %{REQUEST_URI}.html [L,R=301]
Gumbo
Thanks for you response but It didn't work properly. I added some more information to the question.
Neddy
@Neddy: Fixed it.
Gumbo