• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

.htaccess for dummies

Brogan

XenForo moderator
Staff member
#1
I'm sure I'm not the only one who looks at the .htaccess file and thinks "What the...hell?"

I've searched on the net and asked my host for help but I'm still struggling to understand what some of the entries do.

So in attempt to get to the bottom of all the various entries in my .htaccess file, I thought I'd ask here.

First up is this one; what's it for and is it required with a XenForo installation?

Code:
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
 

Jamie

Well-known member
#4
I just checked my .htaccess file on my test site.. standard install and this is what is listed for mine:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
Do you use cPanel by chance?

Jamie
 

Brogan

XenForo moderator
Staff member
#5
I should clarify that this is from the .htaccess file for my current site.

There's quite a lot in there so I just need to know what bits to keep when I migrate to XF, if any.
The standard XenForo .htaccess file has none of the existing entries so I'm just trying to determine whether any of them are needed.
Like this:

Code:
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
 

Blandt

Well-known member
#7
This line disable direct request to those folders (data,js,styles,install)

RewriteRule ^(data|js|styles|install) - [NC,L]
 

Brogan

XenForo moderator
Staff member
#8
I have finally got my .htaccess sorted and fixed all the problems I was having with 403 errors.

Now I'm trying to implement the non-www but it's not working.
Im using this code:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} !^cliptheapex\.com$
RewriteRule ^(.*)$ [URL]http://cliptheapex.com$1[/URL] [R=301,L]
But instead of http://cliptheapex.com/home.php loading, it's trying to load http://cliptheapex.comhome.php - no backslash between com and home.

Can anyone tell me what's wrong with the rewrite string?
 

Brogan

XenForo moderator
Staff member
#10
Getting somewhere...

This works for everything but the home page which gives me a "too many redirects" error:

Code:
RewriteCond %{HTTP_HOST} ^www\.cliptheapex\.com
RewriteRule (.*) http://cliptheapex.com/$1 [R=301,L]
 

mjp

Well-known member
#12
Code:
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
_vti is part of the FrontPage [shudder] file system. Maybe FrontPage created that line, in which case it should be deleted, then burned, then buried under 40 feet of concrete so you're sure it's dead.
 

Brogan

XenForo moderator
Staff member
#13
_vti is part of the FrontPage [shudder] file system. Maybe FrontPage created that line, in which case it should be deleted, then burned, then buried under 40 feet of concrete so you're sure it's dead.
:D I removed that earlier today.
For some reason it keeps getting added back in, possibly due to certain actions carried out in cPanel?

Anyway, my .htaccess has been reduced from about 30 lines of code to 5.
 

mjp

Well-known member
#14
Oh yeah, if it's cPanel and your default site "skeleton" has FP enabled it will keep adding that back.