Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

can't enable mod_rewrite in Apache2 [solved]

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
15 posts • Page 1 of 1
Author
Message
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

can't enable mod_rewrite in Apache2 [solved]

  • Quote

Post by odioworks_com » Thu May 25, 2006 6:10 pm

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: Select all

LoadModule rewrite_module                modules/mod_rewrite.so
I also changed "AllowOverride" to "All" in httpd.conf (not sure if this is needed...):

Code: Select all

<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: Select all

Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

This is my .htacess in my root directory:

Code: Select all

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^(.*)-(.*).html$ index.php?pid=$1&pageTitle=$2
http://www.odioworks.com/index.php?pid= ... cholarship works, while
http://www.odioworks.com/32-An_Entrepre ... rship.html (which should work) doesn't.
Last edited by odioworks_com on Sun May 28, 2006 4:09 pm, edited 1 time in total.
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sat May 27, 2006 7:54 am

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!
Top
lxg
Veteran
Veteran
User avatar
Posts: 1019
Joined: Sat Nov 12, 2005 3:12 pm
Location: Aachen, Germany
Contact:
Contact lxg
Website

  • Quote

Post by lxg » Sat May 27, 2006 10:03 am

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
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sat May 27, 2006 2:55 pm

lx0 wrote:
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: Select all

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.
Top
lxg
Veteran
Veteran
User avatar
Posts: 1019
Joined: Sat Nov 12, 2005 3:12 pm
Location: Aachen, Germany
Contact:
Contact lxg
Website

  • Quote

Post by lxg » Sat May 27, 2006 3:26 pm

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: Select all

<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
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sat May 27, 2006 3:51 pm

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: Select all

<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...
Top
lxg
Veteran
Veteran
User avatar
Posts: 1019
Joined: Sat Nov 12, 2005 3:12 pm
Location: Aachen, Germany
Contact:
Contact lxg
Website

  • Quote

Post by lxg » Sat May 27, 2006 4:44 pm

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
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sat May 27, 2006 5:07 pm

This is an excerpt from my error log. The line occurred when I tried to access test1234 (which didn't exist).

Code: Select all

[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: Select all

[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
Top
lxg
Veteran
Veteran
User avatar
Posts: 1019
Joined: Sat Nov 12, 2005 3:12 pm
Location: Aachen, Germany
Contact:
Contact lxg
Website

  • Quote

Post by lxg » Sat May 27, 2006 5:39 pm

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
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sun May 28, 2006 4:54 am

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: Select all

Include /etc/apache2/vhosts.d/*.conf
in httpd.conf, mod_rewrite breaks. Any ideas?
Top
odioworks_com
Tux's lil' helper
Tux's lil' helper
Posts: 82
Joined: Sun Jan 23, 2005 7:08 pm
Location: Charlottesville, Virginia

  • Quote

Post by odioworks_com » Sun May 28, 2006 5:15 am

Figured it out:

in each of the the vhost conf files change:

Code: Select all

AllowOverride None
to:

Code: Select all

AllowOverride All
Should've caught that earlier...
Top
axlotl
n00b
n00b
User avatar
Posts: 53
Joined: Thu Oct 07, 2004 8:17 pm
Location: Brooklyn, yo

  • Quote

Post by axlotl » Sun Jun 04, 2006 7:01 am

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
Top
Oblong_Cheese
n00b
n00b
Posts: 8
Joined: Tue Aug 16, 2005 7:33 am

  • Quote

Post by Oblong_Cheese » Mon Jul 03, 2006 8:22 am

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!
Top
tessmonsta
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 114
Joined: Thu Jul 28, 2005 5:12 pm

  • Quote

Post by tessmonsta » Wed Jul 05, 2006 2:20 am

ThankyouThankyouThankyou!

I was having the same problem with Drupal 4.7. Now it's all fixed! :D
Top
zietbukuel
l33t
l33t
User avatar
Posts: 607
Joined: Fri Dec 30, 2005 9:45 pm

  • Quote

Post by zietbukuel » Tue Oct 10, 2006 4:57 am

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

Code: Select all

[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: Select all

[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... :?
Top
Post Reply

15 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic