Altec Posted January 19, 2009 Share Posted January 19, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/ Share on other sites More sharing options...
corbin Posted January 20, 2009 Share Posted January 20, 2009 (.*) would mean anything so it would be redirecting to contact/.php or .html... lol. (.*)/?$ should work. Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-740831 Share on other sites More sharing options...
Altec Posted January 20, 2009 Author Share Posted January 20, 2009 I get a 500 Internal Server Error. Without the trailing slash still works fine though. Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-740874 Share on other sites More sharing options...
corbin Posted January 20, 2009 Share Posted January 20, 2009 What exactly did you put in the file? That shouldn't make it 500 error. Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-740886 Share on other sites More sharing options...
Altec Posted January 22, 2009 Author Share Posted January 22, 2009 # BEGIN NoExtensions RewriteEngine On RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule (.*)/?$ $1.html [L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule (.*)/?$ $1.php # END NoExtensions Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-742978 Share on other sites More sharing options...
corbin Posted January 23, 2009 Share Posted January 23, 2009 Hrmmm don't know why that's causing a 500 error. Does the Apache error log say anything useful? Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-744785 Share on other sites More sharing options...
laPistola Posted July 4, 2011 Share Posted July 4, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-1238370 Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2011 Share Posted July 4, 2011 Rather than resurrect a thread that's 2-1/2 years old, please start a new thread with a comprehensive description of your problem, including your .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/141480-no-extensions-htaccess-trailing-slash/#findComment-1238375 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.