What does .htaccess do?

Having trouble installing serendipity?
Post Reply
gfroyle
Regular
Posts: 7
Joined: Thu Mar 30, 2006 10:01 am

What does .htaccess do?

Post by gfroyle »

Installed serendipity on a multi-user system where I do not have root privileges, and unsurprisingly got an "internal server error" immediately after it said "successfully installed".

Checked the web logs and got the message

.../serendipity/.htaccess: DirectoryIndex not allowed here, referer ...

I searched around a little, and believe that I have to ask my sysadmins to change the Apache configuration ... but they will ask why, and given that the page

http://httpd.apache.org/docs/2.2/howto/htaccess.html

essentially says "do not use .htaccess files unless you have to" they will undoubtedly ask me to make a case for why they should allow me to.

But I don't even know what the purpose of that file is - the Apache docs mentioned above say "permit per-directory configuration options" but I would like to explain WHY I need to do this configuration to install s9y.

Thanks in advance.. apologies if this is answered elsewhere, but I couldn't find it easily.

Gordon
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: What does .htaccess do?

Post by garvinhicking »

Hi!

Usually, s9y tries to detect if a .htaccess file can be put online and then chooses the right method for "URL Rewriting". Maybe you changed it from "None" to "Apache Errorhandling" manually?

The .htaccess file is required if you setup URL Rewriting to use "Apache Errorhandling" to create pretty URLs like "/archives/1-my-entry.html" instead of "index.php?/archives/1-my-entry.html". Also .htaccess is used to restrict some people viewing files from your s9y installation.

This usually does no harm, and you can remove the .htaccess if you have problems. But you cannot then use the pretty URL feature.

HTH,Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gfroyle
Regular
Posts: 7
Joined: Thu Mar 30, 2006 10:01 am

Re: What does .htaccess do?

Post by gfroyle »

garvinhicking wrote:Hi!
Usually, s9y tries to detect if a .htaccess file can be put online and then chooses the right method for "URL Rewriting". Maybe you changed it from "None" to "Apache Errorhandling" manually?
I tried to do a "Simple Install"...

All I did was

- download and untar, unzip the package
- move it under my own Web area (on the multiuser system)
- change to world-writable

Then I just went to the serendipity directory with my Web browser.

It reported on our installation - mostly OK, but with a couple of things not present (mbstring, ImageMagick). Then I chose Simple Install.

Next page I typed in the details for my mySQL database - name, password and so on and then went to the next page.

It said "Serendipity installed successfully" and had a link that said something like "Welcome to your new blog" (or maybe "click here for your new blog").

Clicked and immediately got "Internal Server Error".

So I did not make any choices.. I just accepted all the defaults.

As I mentioned, I checked the error logs and saw the error message...

I have subsequently checked with our sysadmins and they confirmed that our Apache server is configured to IGNORE all .htaccess files.

So do I need to convince them to change this? Or can it run in some alternative mode?

Cheers

gordon
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Try going to yourdomain/serendipity_admin.php and logging in. Then you should be able to check the Configuration screen and change the URL rewriting to "none". Let us know what it was beforehand, so we can check the installation logic.
Judebert
---
Website | Wishlist | PayPal
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: What does .htaccess do?

Post by garvinhicking »

Hi!

Okay, I think the issue would be that you chose the simple installation instead of the detailed expert installation. That's all right for you, and we developers will need to inspect why the .htaccess problem was not properly auto-detected.

Now, if you want to use "pretty URLs" you would need to convince your admins to allow .htaccess files. If you can live with the "unpretty URLs", you can just delete your .htaccess file and be happy without it :)

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gfroyle
Regular
Posts: 7
Joined: Thu Mar 30, 2006 10:01 am

Post by gfroyle »

judebert wrote:Try going to yourdomain/serendipity_admin.php and logging in. Then you should be able to check the Configuration screen and change the URL rewriting to "none". Let us know what it was beforehand, so we can check the installation logic.
Unfortunately I have already been to that screen poking around, so I am not sure about what it originally said..

However it seems that the mere existence of an .htaccess file causes the webserver to spit out an error; so I was incorrect when I said it ignored it - instead it actually generates an error message and stops.

But I think that I will be able to get the sysadmins to configure the server to respect .htaccess files for my directory, so I will reconfigure to the default..

Thanks for your help..

I am enjoying playing with s9y already..

Cheers

Gordon
chuckwilliams1
Posts: 2
Joined: Wed Apr 12, 2006 10:55 am
Location: chicago
Contact:

Contents of .htaccess

Post by chuckwilliams1 »

I have a similar problem where I did a simple installation and s9y couldn't write .htaccess. My host told me I can write it myself. So what should I write to my .htaccess file?
---
Chuck Williams
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Contents of .htaccess

Post by garvinhicking »

Hi Chuck!

That depends on the URL Rewriting method you chose. If you have no URL rewriting, you don'T need a .htaccess at all.

With Apache Errorhandling, it needs to contian the directive "ErrorDocument 404 /index.php".

With mod_rewrite it contains many values, that s9y needs to write. For that you need to just create an empty .htaccess file, make it world-writable, run the s9y installer and toggle the URL rewriting to "none" and then to "mod_rewrite" back again, this will re-write the .htaccess file.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mikeh
Posts: 1
Joined: Mon Jul 17, 2006 2:51 am

Post by mikeh »

I just had the same thing happen to me.
That is:
download the 1.0 pacakge; untar; run the installer; setup without error.

Then click on go to your blog link and get the apache internal server error.
Look in the error log and found the actual error: " DirectoryIndexnot allowed here"

After looking around the forum for a second my brain kicked into gear and it dawned on me what the real erorr is:

The .htaccess file that was installed has a line of
DirectoryIndex /serendipity/index.php

but the "DirectoryIndex" apache config command is only allowed in an .htaccess file if the master apache config file has an
AllowOverride Indexes This is not the usual case.

In my case I already have "index.php" as a standard index file in the main configuration file so simply commenting out this line fixed the problem.

If your config file does NOT have index.php then you will want to put it there or allow Indexes as an option in the .htaccess file.
BobMallett
Regular
Posts: 7
Joined: Mon Feb 26, 2007 1:30 pm

I might have solved it

Post by BobMallett »

Hi,

I tried deleteing the .htaccess file which jwas created and ust had the 404 DirectoryIndex directive and ran the install again. I then created a new empty version and made it writeable. Ran the simple install and made it to the completed page. .htaccess now contans

php_value register_globals off
php_value session.use_trans_sid 0

All looking good so far. Will post again if there are any more problems. I have to say the install has been problematic for me on both occasions but once it's running it is very nice, easy to use and robust. Keep up the good work.
:D
Post Reply