0

I've been working on my website for a while and recently have com up to the errors I get if I got to a url with a / after it for instance a directory http://parabolah.cf/documentation/ that would normally forward you to another page doesn't or a page with a slash after it http://parabolah.cf/index/ that just kind of breaks these errors come up with my current .htaccess code:

ErrorDocument 404 /404
ErrorDocument 500 /500
ErrorDocument 206 /206
ErrorDocument 401 /401
ErrorDocument 403 /403
ErrorDocument 408 /408
ErrorDocument 503 /503
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.htm -f 
RewriteRule ^(.*)$ $1.htm
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^documentation$ http://parabolah.cf/documentation/docmain$1[R=301,L]
RewriteRule ^documentation/mi1$ http://parabolah.cf/documentation/mi1/main$1 [R=301,L]
RewriteRule ^documentation/char$ http://parabolah.cf/documentation/char/main$1 [R=301,L]
RewriteRule ^nbtt$ http://parabolah.cf/nbtt/nbtt$1 [R=301,L]

I understand I could with the directories just have a / rewrite rule as well but as far as the parabolah.cf/index/ re-writing to /index/.htm I am clueless. Also, from a non-existent directory in a page, how could I show the 404 page something like parabolah.cf/index/hi ?

Thanks for any help!

parabolah
  • 13
  • 4

1 Answers1

0

You need to change your rule that attached the .htm extension:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.htm -f 
RewriteRule ^(.*)$ $1.htm

to

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.htm -f 
RewriteRule ^(.*?)/?$ $1.htm [L]

so that the trailing slash isn't included in the grouping.

You may also want to make sure multiviews (Options -Multiviews)is turned off and that you links for those pages are all either absolute URLs or you have the correct relative URL base in the page header (<base href="/" />).

Jon Lin
  • 142,182
  • 29
  • 220
  • 220