Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
can't enable mod_rewrite in Apache2 [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Thu May 25, 2006 6:10 pm    Post subject: can't enable mod_rewrite in Apache2 [solved] Reply with quote

I just emerged apache2, and the .htacess file that I had on my previous server (which used mod_rewrite) no longer works.

I load the module in httpd.conf:
Code:
LoadModule rewrite_module                modules/mod_rewrite.so


I also changed "AllowOverride" to "All" in httpd.conf (not sure if this is needed...):
Code:
<Directory />
    Options FollowSymLinks
#    AllowOverride None
    AllowOverride All
</Directory>


When I run apache2ctl -l this is what is returned (not sure if this means anything):
Code:
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c



This is my .htacess in my root directory:
Code:
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^(.*)-(.*).html$ index.php?pid=$1&pageTitle=$2


http://www.odioworks.com/index.php?pid=32&pageTitle=An_Entrepreneur_Scholarship works, while
http://www.odioworks.com/32-An_Entrepreneur_Scholarship.html (which should work) doesn't.


Last edited by odioworks_com on Sun May 28, 2006 4:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sat May 27, 2006 7:54 am    Post subject: Reply with quote

nobody? I've been googling for two days and still can't figure this out... if anyone has any hunch at all about what I'm doing let me know!
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Sat May 27, 2006 10:03 am    Post subject: Reply with quote

Quote:
I also changed "AllowOverride" to "All" in httpd.conf (not sure if this is needed...)


AllowOverride All and FollowSymLinks are mandatory for mod_rewrite.

But: Are you sure mod_rewrite is broken? Or can it be that you've set up faulty rewrite rules?
Usually, when there's a problem with the server's configuration, you'll get an HTTP 500 for the entire (virtual) host.
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sat May 27, 2006 2:55 pm    Post subject: Reply with quote

[quote="lx0"]
Quote:

But: Are you sure mod_rewrite is broken? Or can it be that you've set up faulty rewrite rules?
Usually, when there's a problem with the server's configuration, you'll get an HTTP 500 for the entire (virtual) host.


Normally, I would think that I configured faulty rewrite rules. But I'm perplexed because the rules worked on my previous server.

this is my .htaccess file (trimmed to most important rule):
Code:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteRule ^(.*)-(.*).html$ index.php?pid=$1&pageTitle=$2


This should rewrite 10-Page_Title.html to index.php?pid=10&pageTitle=Page_Title

thanks for your help man.
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Sat May 27, 2006 3:26 pm    Post subject: Reply with quote

Holy Moses, I'm no big mod_rewrite guru at all. I usually take apps that'll create the rewrite rules for me. ;-)

But some ideas that might be worth considering:
- Have you migrated to another Apache series (e.g. 1.3 -> 2.0)? AFAIK the rewrite rules set has changed between the versions.
- IIRC you need to use %{QUERY_STRING} and/or [QSA] when matching against parts of the query string. (Please see the Apache docs.)


Another idea: You could try to determine whether your rewrite engine runs by creating a .htaccess with the following code:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
(courtesy of WordPress)

Then enter an obviously false URL; if you are then redirected to your index.php, you can be sure the rewrite engine works.
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sat May 27, 2006 3:51 pm    Post subject: Reply with quote

lx0 wrote:
Holy Moses, I'm no big mod_rewrite guru at all. I usually take apps that'll create the rewrite rules for me. ;-)

But some ideas that might be worth considering:
- Have you migrated to another Apache series (e.g. 1.3 -> 2.0)? AFAIK the rewrite rules set has changed between the versions.
- IIRC you need to use %{QUERY_STRING} and/or [QSA] when matching against parts of the query string. (Please see the Apache docs.)

Nope, migrated apache2 to apache2. None of the rewrite rules work, even the ones that don't match query strings.


lx0 wrote:
Another idea: You could try to determine whether your rewrite engine runs by creating a .htaccess with the following code:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
(courtesy of WordPress)

Then enter an obviously false URL; if you are then redirected to your index.php, you can be sure the rewrite engine works.

Looks like the engine is not running, since after making this the .htaccess file I'm not redirected to index.php.

Thanks again for your help...
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Sat May 27, 2006 4:44 pm    Post subject: Reply with quote

odioworks_com wrote:
Looks like the engine is not running, since after making this the .htaccess file I'm not redirected to index.php


Well, then let's investigate: Could you append -e debug to your APACHE2_OPTS in /etc/conf.d/apache2? Then restart apache and post the output, please.

What does /var/log/apache2/error_log say?
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sat May 27, 2006 5:07 pm    Post subject: Reply with quote

This is an excerpt from my error log. The line occurred when I tried to access test1234 (which didn't exist).
Code:
[Sat May 27 08:01:23 2006] [error] [client 68.98.189.198] File does not exist: /var/www/odioworks-com/htdocs/test1234



apache output
Code:
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module access_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module auth_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module auth_anon_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module auth_dbm_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module auth_digest_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module charset_lite_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module env_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module expires_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module headers_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module mime_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module negotiation_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module setenvif_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module log_config_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module logio_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module cgi_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module cgid_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module suexec_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module alias_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module rewrite_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module actions_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module autoindex_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module dir_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module ext_filter_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module deflate_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module include_module
[Sat May 27 08:05:26 2006] [debug] mod_so.c(248): loaded module ssl_module
[Sat May 27 08:05:27 2006] [debug] mod_so.c(248): loaded module php5_module


FYI, here's my httpd.conf:
http://www.odioworks.com/httpd.conf

I also enabled apache's rewrite log. I've uploaded that here:
http://www.odioworks.com/rewrite_log
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Sat May 27, 2006 5:39 pm    Post subject: Reply with quote

Well, strange... mod_rewrite appears to be loaded, and I can't see any obvious from the other files you posted, either.

Have you changed anything in the httpd.conf? If so, would it help to restore the original file?

How are your virtual hosts set up? Could you post the vhost configuration file for the above domain? This is also a possible source of hassle.

Or have you done some heavy emerging? If so, what does revdep-rebuild -pv say?
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sun May 28, 2006 4:54 am    Post subject: Reply with quote

lx0 wrote:
Well, strange... mod_rewrite appears to be loaded, and I can't see any obvious from the other files you posted, either.

Have you changed anything in the httpd.conf? If so, would it help to restore the original file?

How are your virtual hosts set up? Could you post the vhost configuration file for the above domain? This is also a possible source of hassle.

Or have you done some heavy emerging? If so, what does revdep-rebuild -pv say?

Restored the original httpd.conf file and disabled vhosts. After changing "AllowOverride None" to "AllowOverride All" the redirect works.

You're right, it seems vhosts is causing the problems. When I enable the line:
Code:
Include /etc/apache2/vhosts.d/*.conf

in httpd.conf, mod_rewrite breaks. Any ideas?
Back to top
View user's profile Send private message
odioworks_com
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jan 2005
Posts: 82
Location: Charlottesville, Virginia

PostPosted: Sun May 28, 2006 5:15 am    Post subject: Reply with quote

Figured it out:

in each of the the vhost conf files change:
Code:
AllowOverride None

to:
Code:
AllowOverride All


Should've caught that earlier...
Back to top
View user's profile Send private message
axlotl
n00b
n00b


Joined: 07 Oct 2004
Posts: 53
Location: Brooklyn, yo

PostPosted: Sun Jun 04, 2006 7:01 am    Post subject: Reply with quote

Quote:
Figured it out:

in each of the the vhost conf files change:
Code:
AllowOverride None

to:
Code:
AllowOverride All


Should've caught that earlier...


T H A N K Y O U.

..for taking solving a source of endless annoying workarounds.
_________________
mucus mules trot tra-la tra-la
Back to top
View user's profile Send private message
Oblong_Cheese
n00b
n00b


Joined: 16 Aug 2005
Posts: 8

PostPosted: Mon Jul 03, 2006 8:22 am    Post subject: Reply with quote

THANK-YOU!!!!!

I was having this problem as well with my Wordpress blog (permalinks not working using mod_rewrite) and was tearing my hair out trying to fix it!

THANKS!
Back to top
View user's profile Send private message
tessmonsta
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jul 2005
Posts: 114

PostPosted: Wed Jul 05, 2006 2:20 am    Post subject: Reply with quote

ThankyouThankyouThankyou!

I was having the same problem with Drupal 4.7. Now it's all fixed! :D
Back to top
View user's profile Send private message
zietbukuel
l33t
l33t


Joined: 30 Dec 2005
Posts: 607

PostPosted: Tue Oct 10, 2006 4:57 am    Post subject: Reply with quote

This doesn't work for me :( apache is crazy it is looking for some "home" & "htdocs" files, see:

Code:
[Mon Oct 09 23:52:21 2006] [error] [client 127.0.0.1] File does not exist: /usr/htdocs, referer: http://bavrit.eth0.ws/~ziet/Portal/

(this is without vhosts)

Code:
[Mon Oct 09 23:56:38 2006] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/home, referer: http://bavrit.eth0.ws/~ziet/Portal/

(This is with vhosts enabled)

I have:

AllowOverride All

And mod_ewrite enabled, what is wrong?? if you need more info about my config, just ask, please, thank you.

Apache thinks "/usr/lib/apache/htdocs" is "/" wtf?

ps. im using apache-1.3, i have the same with apache-2.0... :?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum