0

So here's what my htaccess clean url code look like:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond  %{QUERY_STRING} !^myvar=0
RewriteCond %{REQUEST_URI} !\..*$
RewriteRule ^([^/]*)/?$ /$1.php?myvar=0 [QSA,L]

This htaccess code permits files on the root to work with .php, trailing slash, or nothing. So blah.com/blah.php works blah.com/blah works blah.com/blah/ works

However if there's a folder on my root, say the name is 'news', the file 'news' on the root cannot take on a clean url. So blah.com/news.php works but blah.com/news and blah.com/news/ both do not work.

For some reason, files inside a folder must have a file extension (.php), so blah.com/news/obama.php works blah.com/news/obama and blah.com/news/obama/ both do not work.

What's wrong with the .htaccess code and how can I correct it?

tl;dr Is there an htaccess code that can make it so .php works, trailing slash works, and no trailing slash works? I know absolutely nothing about htaccess.

Also: I posted this same question yesterday but was met with no reply. Not sure why. If there is something confusing, I'll try to clear it up. Thanks!

user758287
  • 137
  • 1
  • 2
  • 8

1 Answers1

0

Maybe

RewriteBase /
RewriteRule ^(.*)(?=\.php/?)?$ /$1.php?myvar=0 [QSA,L]

could help. Your log files are really golden in this case.

planestepper
  • 3,277
  • 26
  • 38