Simple .htaccess question

1 replies
Hi,
I'm new to .htaccess and was wondering whether my .htaccess file is correct.

My homepage is on index.html. It's a static HTML site that makes use of php include on a few of the HTML pages.

This is the content of my .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ %{DOCUMENT_ROOT}/index.php [L]
AddType application/x-httpd-php .htm .html


I don't really understand the code and actually copied it from a tutorial website. I have a feeling the RewriteRule line is not correct. I should change the "index.php" to "index.html" right?

As for the AddType line, does it mean run all .htm and .html file as php?

Thank you for your help!
#htaccess #question #simple
  • Profile picture of the author theIMgeek
    Hi Daedric,

    The htaccess info you posted there is actually two seperate rules.

    The first four lines say that is a URL is not a file (!-f) and is not a directory (!-d) then it wil display the contents of your main index.php file. This sort of thing is used by dynamic websites (like Wordpress) so that you can show pages that don't physically exist. In a static website, this is probably not needed.

    Now, you might want to add a new rule like this...

    ErrorDocument 404 /notfound.html

    And create your 404 eror page to display when people visit a page that does not exist.

    The last line (AddType) is a seperate command, and it does as you suspect. It tells your website to process .html and .htm as if it was a .php file. So it should process anything inside <?PHP ?> tags.

    -Ryan
    Signature
    FREE WSO: Protect and Automatically Deliver Your Digital Products

    Ask the Internet Marketing Geek
    <-- Happy to help with technical challenges
    MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy
    {{ DiscussionBoard.errors[2767954].message }}

Trending Topics