Forum Moderators: phranque

Message Too Old, No Replies

New to htaccess

Will this code do any harm?

         

steve

7:09 pm on Aug 9, 2007 (gmt 0)

10+ Year Member



I've just moved from IIS to Apache. So this is my first attempt at htaccess, and this is what I have so far:


# allow all pages to execute php
AddType php-script .php .php3 .html .htm .asp

#make sure error page returns 404 not 200!
ErrorDocument 404 /custom404.htm

RewriteEngine On
RewriteBase /

# redirect domain.com to www.mydomain.com
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

# redirect index.ext to /
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php多tml多tm地sp)\ HTTP
RewriteRule ^(.*)index\.(php多tml多tm地sp)$ /$1 [R=301,L]

#redirect default.ext to /
RewriteCond %{THE_REQUEST} ^GET\ .*/default\.(php多tml多tm地sp)\ HTTP
RewriteRule ^(.*)default\.(php多tml多tm地sp)$ /$1 [R=301,L]

I've tested it against every possibility I can think of and it appears to be OK. (NB the broken bars are actually solid!)

Have I done anything which may harm my site, or are there any improvements I could add?

/Steve

steve

7:45 am on Aug 10, 2007 (gmt 0)

10+ Year Member



I've found one problem with this setup.

I directories which have an index.asp (the site was previously on IIS) links to /, index.asp, index.php, etc throw a 403 forbidden. Non index asp pages work fine.

I've worked round this by renaming the offending pages index.php. But I'd really like to understand what is causing this, can anyone shed any light?

/Steve

jdMorgan

3:52 pm on Aug 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Take a look at your Apache error log when you get a 403. It may be quite helpful in determining what the problem is. Without that information, there could be many, many things that invoke a 403-Forbidden response, from an undefined or mis-defined DirectoryIndex to file-execute permissions problems.

Jim