New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

using .htaccess files

Got problems with your B2 or B3? Share and get helped!
Post Reply
toukie
Posts: 115
Joined: 13 Jan 2012, 12:22

using .htaccess files

Post by toukie »

I would like to use .htaccess for different things like custom error pages and maybe for banning some IP's.

I have changed "AllowOverride None" to "AllowOverride All" in /etc/apache2/sites-enabled/bubba, and I have a .htaccess file in /home/web and a custom "error404.htm" page in folder: /home/web/errordocs. Why doesn't Apache pick it up?

/etc/apache2/httpd.conf has: "AccesFileName .htaccess"

How do I enable .htaccess on B3?
Kiff
Posts: 48
Joined: 08 Feb 2010, 04:09
Location: Norway
Contact:

Re: using .htaccess files

Post by Kiff »

Have you restarted apache after you changed "AllowOverride"?
toukie
Posts: 115
Joined: 13 Jan 2012, 12:22

Re: using .htaccess files

Post by toukie »

I have restarted several times, what else could it be?
I want to use .htaccess to make a nice custom 404-error page with Troll Face and the word "problem?" for all those who are looking for phpMyAdmin on my server (I didn't install it, it seems to be a security risk)
nobody
Posts: 226
Joined: 10 Mar 2012, 14:46

Re: using .htaccess files

Post by nobody »

try to see if your htaccess is read by apache by entering a typo in it and reloading apache. Then look in the error logs if apache complains.
As many directives in apache can be applied from different angles (location, virtualhost, directory) this is the quickest way to see if the htaccess is used :)
toukie
Posts: 115
Joined: 13 Jan 2012, 12:22

Re: using .htaccess files

Post by toukie »

still no joy with .htaccess files, but I found out that custom error-pages are done with
/etc/apache2/conf.d/localized-error-pages. My custom 404-error page is now a really nice one!

OwnCloud uses .htaccess, so it would be good to know how to enable it. I don't know, maybe Apache rewrites the AllowOverride at reboot, mine was anyway back to "None" when I checked.
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: using .htaccess files

Post by Ubi »

toukie wrote:I don't know, maybe Apache rewrites the AllowOverride at reboot, mine was anyway back to "None" when I checked.
It most certainly does not do that :D . Most likely the position you put your directive is ignored or overruled by another directive,
toukie
Posts: 115
Joined: 13 Jan 2012, 12:22

Re: using .htaccess files

Post by toukie »

"It most certainly does not do that".

In that case it would be nice to know where those overruling directives are found.
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: using .htaccess files

Post by Ubi »

Yeah I know, and if I would know I'd have told you. Searching for the winning rule can be a pain, and I cannot give you an easy answer except that there is no resetting done by apache at boot time.
toukie
Posts: 115
Joined: 13 Jan 2012, 12:22

Re: using .htaccess files

Post by toukie »

Apache says that you are not supposed to do things with .htaccess.

https://httpd.apache.org/docs/current/h ... ccess.html

"However, in general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a <Directory> section in your main server configuration file."

OwnCloud uses .htaccess: "If you are running the apache webserver, it is recommended that you enable .htaccess files as ownCloud uses them to enhance security and allows you to use webfinger."
nobody
Posts: 226
Joined: 10 Mar 2012, 14:46

Re: using .htaccess files

Post by nobody »

Well of course, that would be because owncloud does not allow you access to their main server config. Allowing modifications via htaccess is the next best thing.
However, on the B3 you are the admin and you do have access to the main config. In that case, placing directives in the main config is preferred, not in the least because these directives are not processed after every http request.
Post Reply