Leates
August 6, 2011, 9:43pm
#1
Hi, I need some help with .htaccess.
I am trying to get one of my directories only accessible by the staff members of my site, using IP adresses and .htaccess.
It seems to be working, but the errordocument isn’t appearing for the users that aren’t allowed to access, they are just being redirected to http://error404.000webhost.com/ ?
The ErrorDocument section of my .htaccess file is this:
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
And yes, there are also 403.html and 404.html pages in the public_html folder AND the directory.
Many Thanks
Leates
shekii
August 6, 2011, 10:12pm
#2
The same is happening to me I haven’t changed anything .htaccess.
Could a staff member help us?
Leates
August 6, 2011, 10:40pm
#3
Any staff members able to help?
drums
August 6, 2011, 11:48pm
#4
How did you create your .htaccess file and put it on the server? Sometimes if it’s not created in a proper (raw) text editor, then it can create problems.
What else is in your .htaccess? Can you post the whole htaccess file (replacing #'s for any “sensitive” information)
shekii
August 7, 2011, 10:40am
#5
Here have a look.
Options -MultiViews +FollowSymlinks -Indexes
If mod_security is enabled, attempt to disable it.
- Note, this will work on the majority of hosts but on
MediaTemple, it is known to cause random Internal Server
errors. For MediaTemple, please remove the block below
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off
# The below probably isn't needed, but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
MyBB “search engine friendly” URL rewrites
- Note, for these to work with MyBB please make sure you have
the setting enabled in the Admin CP and you have this file
named .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^forum-([0-9]+).html$ forumdisplay.php?fid=$1 [L,QSA]
RewriteRule ^forum-([0-9]+)-page-([0-9]+).html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]
RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]
RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]
RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]
RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]
RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]
RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]
<IfModule mod_env.c>
SetEnv SEO_SUPPORT 1
</IfModule>
</IfModule>
If Apache is compiled with built in mod_deflade/GZIP support
then GZIP Javascript, CSS, HTML and XML so they’re sent to
the client faster.
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript text/css text/html text/xml
</IfModule>
Leates
August 7, 2011, 4:47pm
#6
Mine was created and is edited in Notepad.
The one in the staff only directory is:
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
deny, allow
deny from all
allow from #.#.#.#
The one in the public_html folder is
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
Many Thanks
Leates
you10
August 7, 2011, 6:10pm
#8
Leates:
Mine was created and is edited in Notepad.
The one in the staff only directory is:
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
deny, allow
deny from all
allow from #.#.#.#
The one in the public_html folder is
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
Many Thanks
Leates
In the staff only directory is there a 403.html and a 404.html file.
Leates
August 7, 2011, 8:43pm
#10
Anyone that can help?
Apparently this is bumping.
It was not intended, and I find it funny how the moderator just said it was bumping and did not help.
Leates:
Anyone that can help?
Again, you’re bumping. Please stop.
drums
August 8, 2011, 1:51am
#12
Try using Notepad++. Notepad (the default one that comes with Windows) has “broken” CR/LFs, which can sometimes cause compatibility issues between unix / win.
Leates:
The one in the staff only directory is:
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
deny, allow
deny from all
allow from #.#.#.#
The one in the public_html folder is
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
Okay, try changing the “deny, allow” line to:
order deny, allow
You don’t need to have separate “ErrorDocument” lines in your subdirectory’s htaccess files, as it’s inherited from above.
See how you go!
drums
Leates
August 8, 2011, 11:07am
#13
The .htaccess file in the directory was edited in Notepad++
This is what it looks like now:
order deny, allow
deny from all
allow from 68.61.164.76
The error page still does not show up.
drums
August 9, 2011, 12:05am
#14
Are you sure? I can get it to show up.
I don’t get the 403 page when I go to the staff directory though, I get 404 (but 000webhost’s).
drums
Leates
August 9, 2011, 12:26pm
#15
What can you get to show up? The site’s 404 page?
That is what I’m trying to solve.
Leates
August 10, 2011, 9:35am
#16
My 404 page works all-over the site, but this just doesn’t seem to be working.
Just the problem again so you understand it: My 403 page won’t show up when someone is denied access into my staff directory. It goes by IPs in the .htaccess file, inside that directory.
drums
August 10, 2011, 12:22pm
#17
Okay… reading back through the posts, should’ve picked this up earlier, but it’s case sensitive…
Try:
Order Deny,Allow
Deny from all
Allow from #.#.#.#
Leates
August 10, 2011, 4:53pm
#18
THANKS DRUMS!!!
Are you the most helpful person here?
Lol.
dan09
August 11, 2011, 8:05am
#19
Is the .htaccess in the same directory as the 404 and 403 files