Forum Moderators: phranque
I have spent all day reading, mostly on this website, trying to figure out how to make my previously working redirects work under Apache 2.2.X as my host recently upgraded.
Primarily, I used mod rewrite to remove .php from the end of files. However, I also had it working so that www.example.com/topic would work without returning a 403 error even though a directory at www.example.com/topic/ exists without an index.php file inside it. (Basically, Apache wouldn't look for /topic/index.php, but rather for /topic.php and remove the .php) I hope this makes sense.
The line that seems to no longer work (bolded in the code below) was something I came up with to allow for what I explained above. It seems like it may have been the wrong way to tell Apache to look for a file with the same name as a directory ather than inside the directory for it's index file, especially since it no longer works, but any tips or suggestions would be greatly appreciated.
--------------------------------
# MOD REWRITE
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301]
#removes .php
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
#removes "index"
RewriteRule (.*)/index$ $1 [R=301]
#removes "/"
RewriteRule (.*)/$ $1 [R=301]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
------------------------------------