I have to put /index.php to access my site

I was messing with the htaccess file today. I have a couple of URL rewrites and then I put some code to close the site down to all users except for my ip address and redirect them to a site down page.

I have no idea what I did but I cannot access my site through just www.mysite.com.

I have to put www.mysite.com/index for it to work, otherwise I get a 404.

Here is my code in my htaccess file.

Options +FollowSymLinks

#landing page url rewrite#
RewriteRule ^fabtech(\\.php|\\.html|)$ FabTech.php
#end landing page rewrite#

RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*)\\.html$ $1.php [NC]
#RewriteRule ^([^\\.]+)$ $1.php [NC,L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !\\.php$
RewriteRule ^(.*)$ $1.php [NC,L,QSA]

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache

# Turn on mod_rewrite
RewriteEngine On
# If not your IP address
RewriteCond %{REMOTE_ADDR} !^98\\.103\\.33\\.82
# and not the temporary page
RewriteCond %{REQUEST_URI} !^/maintenance\\.php$
# redirect to temporary page
RewriteRule /*$ /maintenance.php [L]

Quick background on what I’m trying to achieve with those rewrites.

I have a URL that looks like this www.mysite.com/ThisPage

  1. I needed to code a rewrite that would allow a user to not have to include .html or .php.
  2. Because the URL has capitalization (The “T” and the “P”), I had to make sure that would work as well.


Aha! A specification!

If the {REQUEST_FILENAME}.php exists, redirect to it.
If the {REQUEST_FILENAME}.html exists, redirect to it.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME}\\.php$ -f
RewriteRule ^([a-zA-Z/]*)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME}\\.html$ -f
RewriteRule ^([a-zA-Z/]*)$ $1.php [L]

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.



For what it’s worth, I copy/pasted your htaccess, and as long as my DirectoryIndex was set to index.php, it worked just fine. There may be something else going on that we haven’t seen.

It’s definitely in your interest to start using a version control system, such as Git. That way you’ll always know what you did and can always revert to an earlier version.