*sob*...clean urls, .htaccess, mod_rewrite.....can't...take...it...anymore...

VinceDee - March 15, 2006 - 20:19

I seriously doubt if anyone here can help with this, but I just can't get clean URLs working on my Drupal install.

I'm running my own LAMP server (Ubuntu Linux, Apache2, MySQL, PHP) and I think I've done what I'm supposed to do to get mod_rewrite running on my Apache server (according to my post on the Ubuntu Forums here: http://www.ubuntuforums.org/showthread.php?t=144782), but every time I put the default .htaccess into my Drupal directory, my website goes down.

So I tried a modified version of the .htaccess file, with only the IFModule/RewriteEngine On portion of it uncommented, and the Drupal admin/settings/clean URL just returned a:

"It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator."

Does anyone here have an idea of what I'm doing wrong, or settings that need to be changed for me to use clean URLs?

Vince

What directory is your

sepeck - March 15, 2006 - 20:35

What directory is your Drupal installed in? If it's in a sub directory you may need to edit htaccess to account for that sub dir path

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

Might Be Too Simple...

geme4472 - March 15, 2006 - 20:58

...but if your domain hasn't propogated, you can't use clean URLs. (if this is blatantly obvious, I apologize)

Your ISP might have mod_rewrite disabled

pulsifer - March 15, 2006 - 21:15

Your ISP might have mod_rewrite disabled. There are a few ways to find out:

1. ask them

2. put this code in a file called phpinfo.php, upload it to your root directory, then navigate to www.yoursite.com/phpinfo.php:

<?php phpinfo(); ?>

Look in the apache section of the output, in "Loaded Modules", and see if you can find mod_rewrite.

3. Add these two lines to the top of the .htaccess in your root directory:

RewriteEngine on
RewriteRule .* http://drupal\.org [L,R]

If mod_rewrite is working, then whenever you go to your website you should be redirected to drupal.org

if its your own server...

pulsifer - March 15, 2006 - 21:25

If its your own server, you can take the IFModule out of the .htaccess because you know it will be there.

You can also add these two lines to your .htaccess:

RewriteLog some-valid-path-to-a-log-file
RewriteLogLevel some-number-between-0-and-9--try-3-to-start

Then check your apache server logs as well as the rewrite log file you specified.

Note that most ISP's don't allow you to turn RewriteLog on because it can bog the server.

take out IfModule

pulsifer - March 15, 2006 - 21:26

Definitely take out the "IfModule mod_rewrite.c". Then if mod_rewrite isn't loaded, the "RewriteEngine on" will cause an error msg in your server log.

I had to do this

jo1ene - March 15, 2006 - 22:11

I had to do this myself.

Advanced Web Design

.

VinceDee - March 15, 2006 - 21:22

sepeck, it's in the root directory, so I left the subdirectory part commented out

geme4472, the domain's been around for several weeks now, so I'm pretty sure it's as propagated as it's gonna get. Thanks for the suggestion, though.

pulsifer, I'm running my own server so I'm not sure why I'd need my ISP to have mod_rewrite enabled. That's an interesting suggestion about the redirecting, though, I'll try that out when traffic slows enough on my site sometime today (in case it causes it to go down).

Here's my link, in case it would do you any good:
http://www.ubuntuwebservers.com

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

.htaccess

bugz_nz - March 15, 2006 - 21:37

Hey Vince,

I had a similar problem - couldn't activate url rewrite even thought I knew it was configured correctly on the server.

I eventually edited my .htaccess file to say:

RewriteBase /

This is under the various rewrite rules section.

This got me working straight away.

httpd.conf

satanas - March 15, 2006 - 22:03

Did you guys check whether the directive AllowOverride is set to "All".

e.g

<Directory "/path_of_your_site">

   AllowOverride All

</Directory>

This is Just a suggestion.. :)

S.

yes, did this

VinceDee - March 15, 2006 - 22:18

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

Seconded

therave - March 15, 2006 - 22:20

Yeah - I built my own Linux development server recently (using Centos), and found, to my surprise, that the default httpd.conf had 'AllowOverride None' as the setting for all sites.

Strongly recommend you check for that as no rewrites will work when that is the case.

David Hamilton
http://www.jiffle.net/

I just tried this

VinceDee - March 15, 2006 - 22:22

But it didn't work for me...same result...site was not accessible

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

.htaccess

meba - March 15, 2006 - 21:57

please paste your .htaccess, especially last 10 lines

Here's my .htaccess file

VinceDee - March 15, 2006 - 22:17

It's 100% default. With my Drupal installation in the root directory, there isn't anything I should have to change, is there?

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order deny,allow
Deny from all

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More exist in sites/default/settings.php, but
# the following cannot be changed at runtime. The first IfModule is
# for Apache 1.3, the second for Apache 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

# Reduce the time dynamically generated pages are cache-able.

ExpiresByType text/html A1

# Various rewrite rules.

RewriteEngine on

# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /drupal

# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.66 2005/03/20 19:15:00 dries Exp $

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

Try prefixing the rewrite destinations with /

therave - March 15, 2006 - 22:29

I recently found a case where rewriting didn't work when hosted by 1and1. The solution turned out to be to prefix all of the rewrite destinations with '/'.

E.g.

  #RewriteRule node.php /index.php?q=node/view/%1 [L]

...
  #RewriteRule module.php /index.php?q=%1 [L]

... and
  RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

The rewrites were generating errors if rewrites were enabled, until this change was applied. Your mileage may vary, or course.

Regards
/david

David Hamilton
http://www.jiffle.net/

Thanks, David

aserdaten - March 30, 2006 - 21:58

David's suggestion cleared up a problem that's been driving me bats for three days. I moved a dev site to Network Solutions from Dreamhost, and there are so many oddities about Network Solutions hosting that I couldn't figure out which one was responsible.

For future Network Solutions customers looking for the answer to this question, remove this line from .htaccess at about line 42:

<IfModule mod_rewrite.c>

Because "Network Solutions doesn't run rewrite as a module", though it is in some ineffable zen way present nonetheless, so just remove the 'If' condition and it works.

Also, do what David says and add '/' before all rewrite destinations

Those two changes cleared up my Network Solutions problems.

Don't bother asking Network Solutions tech support for help because they don't know. They are very polite in telling you they don't know and don't waste your time pretending they do, which puts them in the top 5% of tech support in my book, regardless of being utterly useless in this unique circumstance.

Did you try #3?

pulsifer - March 15, 2006 - 22:39

Did you try #3 in http://drupal.org/node/54231#comment-102501? What happened?

I just tried it

VinceDee - March 15, 2006 - 22:48

I made a blank .htaccess file and put that string by itself in it:

RewriteEngine on
RewriteRule .* http://drupal\.org [L,R]

I refreshed my website and it sent me to drupal.org!

so, doesn't that mean that my mod_rewrite is working? If so, then what could be the problem?

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

Update

VinceDee - March 15, 2006 - 23:25

I just narrowed down who the culprit is. It's these 2 guys:

Options -Indexes
Options +FollowSymLinks

I started with a default htaccess file and deleted all the comments, so I could see a simplified version. Then began by trying to run the file as is. Naturally, it was a nogo and my site was not accessible.

I next commented out the first two lines and ran the file: still a nogo

when I commented out the next two lines (those two above), my site stayed up. So, I left those commented and uncommented the first two lines. Then I got a "Forbidden: access denied" message, but that's a lot more promising than the previous "500 server error, and a host of other problems" message.

Either by itself or both of those two lines has the same effect of not working.

Does this help to make it any clearer to anyone what the problem might be?

Vince

and here's my latest slimmed-down htaccess file:

Order deny,allow
Deny from all

#Options -Indexes
#Options +FollowSymLinks

ErrorDocument 404 /index.php

DirectoryIndex index.php

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

ExpiresByType text/html A1

RewriteEngine on

RewriteBase /

#Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.66 2005/03/20 19:15:00 dries Exp $

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

The problem is a 500 server error?

pulsifer - March 15, 2006 - 23:25

So the problem is a 500 server error when using Drupal's .htaccess? What does the server error log say?

Here's what the log says

VinceDee - March 15, 2006 - 23:58

[Wed Mar 15 15:44:29 2006] [alert] [client 24.7.108.240] /var/www/web6/web/.htaccess: Options not allowed here, referer: http://www.ubuntuwebservers.com/
[Wed Mar 15 15:44:29 2006] [alert] [client 24.7.108.240] /var/www/web6/web/.htaccess: Options not allowed here, referer: http://www.ubuntuwebservers.com/
[Wed Mar 15 15:45:28 2006] [error] [client 207.46.98.57] File does not exist: /var/www/web6/web/robots.txt

That last entry reminds me of what my next project has to be for this site: create a robots.txt file

Anyway, can you tell anything from those last three error.log entries? I'm too much of a newb to know what they mean.

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

one problem at a time...

pulsifer - March 16, 2006 - 00:11

If you remove the Options or comment them out (by prefixing them with a #), then everything works?

Yes, it works...

VinceDee - March 16, 2006 - 00:17

...if I comment out the two Options lines and the two first lines (with those in I get a "Forbidden: Access denied" message).

those error.log lines were from the server's /var/logs/ directory. Here's one from the website's directory:

[Wed Mar 15 16:11:24 2006] [alert] [client 24.7.108.240] /var/www/web6/web/.htaccess: Options not allowed here, referer: http://www.ubuntuwebservers.com/?q=toboggan/register

seems to be essentially the same, but it refers to the toboggan login.

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

huh?

pulsifer - March 16, 2006 - 00:25

You commented out all this:

Order deny,allow
Deny from all
Options -Indexes
Options +FollowSymLinks

and you're still getting an "Options not allowed"?

Are you sure that's not an old msg? Try clearing the log, or refresh the page and watch the time stamps closely to make sure you're still getting that error. Also, what url are you going to? What is your browser give you? A page of text that says what? A pop-up error msg that says what?

No, the error message

VinceDee - March 16, 2006 - 00:32

was with those 4 lines enabled (not commented out). When I comment out the Options lines and leave the other 2 enabled, I get a "Forbidden Access" message. when I comment out all 4 lines then everything appears to work properly.

Here's a jpg of the message that pops up in the browers:

http://www.ubuntuwebservers.com/500servererror.jpg

Vince

btw, I know it's got to be frustrating to you but I appreciate you helping me...it's above and beyond the call.

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

Almost there...

pulsifer - March 16, 2006 - 01:07

The problem with the first two lines is that you may not have the stock .htaccess file. Look at the actual file here: http://cvs.drupal.org/viewcvs/drupal/drupal/.htaccess?view=markup

Notice the FilesMatch lines before and after Order...Deny. Does your .htaccess have those? They are critical. (I've seen these lines missing before because things enclosed in lt gt signs like to get lost when viewed on web pages.)

The problem with the Options lines is that your server is not recognizing the "AllowOverride All". Maybe its not in the right place, maybe it has a typo, maybe the name of the vserver its applied to has a typo, etc. I don't know, but something like that is most likely the problem.

P.S.

pulsifer - March 16, 2006 - 01:17

P.S. Another possibility is conflicting AllowOverride statements. Look for an AllowOverride None. In theory though you should be able to have an AllowOverride None at the head of your conf, and then override it with AllowOverride xxxx in specific vhosts, in specific directories, etc.

this is interesting

VinceDee - March 16, 2006 - 03:15

I have another website that I'm just starting to develop, based on Wordpress. Same server, same basic setup as the Drupal site that I'm having so much trouble with:

http://www.gadgetbugs.com

To see if mod_rewrite worked for that site, I enabled their simple URLs on it. After creating the .htaccess file manually (they don't provide you with one) and inserting the text that they provide, it worked...perfectly.

So, apparently mod_rewrite is enabled on the server, and works with at least one of my websites.

I've also looked at all the configuration files there are for apache2 and changed practically any AllowOverride that I found to All.

I'm getting the same result every time when I enable the htaccess file: my site gives a 500 server error.

I'm out of answers. Especially since mod_rewrite works with Wordpress.

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

what's not working?

pulsifer - March 16, 2006 - 04:05

From my understanding of what you have said, mod_rewrite and clean url's are working fine, as long as you comment out those offending four lines.

The four lines causing problems have nothing to do with mod_rewrite. They restrict access to certain files on the server for security purposes. Whether you have mod_rewrite or not, it is still a good idea to get those four lines working.

Still not working

VinceDee - March 16, 2006 - 05:16

I just tried commenting out all four lines and running it. My site is accessible that way, but no clean URLs, which of course defeats the purpose of the whole exercise.

I'll keep messing around with it and let you know if I figure it out.

Thanks for the help,

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

P.S.

pulsifer - March 16, 2006 - 00:32

Is "/var/www/web6/web/.htaccess" the .htaccess in your page root, or is it in a subdir? Are you sure that's the file you are looking at, the one in which you commented out the "Options"?

That's the one

VinceDee - March 16, 2006 - 00:36

It's definitely the same .htaccess file. I'm using ISPConfig so my system has /var/www/web6/web/ as the subdirectory and page root directory for this website.

I just went over to the server and checked just to make absolutely sure, but it's the same directory. I should have explained that probably.

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

P.S.

pulsifer - March 16, 2006 - 00:16

You probably need to add

AllowOverride All

to your apache .conf file. See http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride

I did add AllowOverride All

VinceDee - March 16, 2006 - 00:19

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

yes, mod_rewrite is working

pulsifer - March 15, 2006 - 23:23

Yes, it looks like mod_rewrite is working. I suggest reinstalling the Drupal .htaccess (without the IFModule statements), then add the logging options I mentioned in http://drupal.org/node/54231#comment-102504. Add them right after "RewriteEngine on". If you turn the RewriteLogLevel up high enough (it goes to 9), somewhere in your logs (either the server logs or the Rewrite log) will be some clues about what is going wrong.

PROBLEM SOLVED

VinceDee - March 16, 2006 - 22:49

You can see my extremely long-winded solution to these various problems here:

http://drupal.org/node/54425

Vince

---------
The hottest Linux distribution? Ubuntu
Talk about Ubuntu Web Servers at:
http://www.ubuntuwebservers.com

 
 

Drupal is a registered trademark of Dries Buytaert.