Jump to content

No Extensions - .htaccess - Trailing Slash?


Altec

Recommended Posts

Righto, I have this in my .htaccess file:

# BEGIN NoExtensions
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule (.*) $1.html [L]
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule (.*) $1.php
# END NoExtensions

Which works fine for URLs like mysite.com/contact, mysite.com/about, but not for URLs like mysite.com/contact/, mysite.com/about/ with a trailing slash. I'm really terrible with regular expressions, and I fail when trying to get it to recognize the trailing slash.

 

In doing so I realized by adding a trailing slash I could potentially block all my subdirectories from being accessed, so how can I whitelist the file (URLs) I want to rewrite?

Link to comment
https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/
Share on other sites

  • 2 years later...

Hello

 

I have been looking for the very same solution and after trying your amendment in my htaccess file I got the 500 error. My logs state this:

 

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.