Apache Server configuration support - mod_rewrite trouble

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2007 > mod_rewrite trouble





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author mod_rewrite trouble
IamDave

2007-08-10, 1:24 pm

I'm kinda new to this and I'm having trouble getting mod_rewrite to
work with Apache 2.2 on Ubuntu 7.04. I ran the command "sudo a2enmod
rewrite" and it said that the module was installed. I then did a
force-reload on the server and have since restarted the server several
times. As a test, in my .htaccess file I put the following:

Options +FollowSymlinks

RewriteEngine On
RewriteRule ^dave\.html$ test.php [R]

But it doesn't do anything. I've also tried putting this stuff in the
virtual host config file and it didn't do anything there either. I
don't have any idea what else to try and hours of Googling haven't
revealed anything useful. I'm beginning to wonder if maybe
mod_rewrite is an elaborate hoax.
Dave

Davide Bianchi

2007-08-10, 1:24 pm

On 2007-08-10, IamDave <raven187@gmail.com> wrote:
> As a test, in my .htaccess file I put the following:
>
> Options +FollowSymlinks
>
> RewriteEngine On
> RewriteRule ^dave\.html$ test.php [R]


First step when debugging something is to enable logging and see if it
does start logging and what it says, so add a RewriteLog somewhere and
see if you get something logged in. If it doesn't, then the Rewrite
directives are ignored.

When you get the info, check what does it says.

One step at a time.

Davide

--
If Microsoft were to vanish, who would we hate next?
-- From a Slashdot.org post
IamDave

2007-08-11, 7:19 am

Okay, I added RewriteLog /etc/apache2/sites-enabled/rewrite_log.txt to
the virtual host configuration but nothing has been logged. Does that
mean that even though the module is installed it's not activated or
something? Where should I go from here? And thanks for responding!
Dave

On Aug 10, 9:10 am, Davide Bianchi <davideyeahs...@onlyforfun.net>
wrote:
> On 2007-08-10, IamDave <raven...@gmail.com> wrote:
>
>
>
>
> First step when debugging something is to enable logging and see if it
> does start logging and what it says, so add a RewriteLog somewhere and
> see if you get something logged in. If it doesn't, then the Rewrite
> directives are ignored.
>
> When you get the info, check what does it says.
>
> One step at a time.
>
> Davide
>
> --
> If Microsoft were to vanish, who would we hate next?
> -- From a Slashdot.org post


Davide Bianchi

2007-08-11, 7:19 am

On 2007-08-11, IamDave <raven187@gmail.com> wrote:
> Okay, I added RewriteLog /etc/apache2/sites-enabled/rewrite_log.txt to
> the virtual host configuration but nothing has been logged. Does that
> mean that even though the module is installed it's not activated or
> something?


If the log file shows up, it means that the module is loaded and the
directive is read, but the rewrite rule is never applied or reached.
On the other hand, if the log doesn't even appear, it means that the
vhost is never initialized. Since your rewrite rule is in the .htaccess
file, are you sure that file is processed? Do you have an
AllowOverride in your vhost?

> Where should I go from here?


I suggest you use apachectl configtest to check if there are obvious
errors in your configuration, then post your configuration so we can
have a look and maybe spot the error.

Davide

--
Who's this 'general failure'? And why is he reading my disk??
IamDave

2007-08-13, 1:26 pm

On Aug 11, 5:02 am, Davide Bianchi <davideyeahs...@onlyforfun.net>
wrote:
> On 2007-08-11, IamDave <raven...@gmail.com> wrote:
>
>
> If the log file shows up, it means that the module is loaded and the
> directive is read, but the rewrite rule is never applied or reached.
> On the other hand, if the log doesn't even appear, it means that the
> vhost is never initialized. Since your rewrite rule is in the .htaccess
> file, are you sure that file is processed? Do you have an
> AllowOverride in your vhost?
>
>
> I suggest you use apachectl configtest to check if there are obvious
> errors in your configuration, then post your configuration so we can
> have a look and maybe spot the error.
>
> Davide
>
> --
> Who's this 'general failure'? And why is he reading my disk??


Okay, I did that and it said the syntax was ok. Also, the log file is
showing up but nothing is being logged in it. I was initially putting
the rewrite stuff in the vhost but I switched to .htaccess to see if
it made a difference. I've gone back to doing it in the vhost now and
below is my configuration:

<VirtualHost *>
ServerAdmin dwill@ravenflight.net
ServerName www.ravenflight.net
ServerAlias ravenflight.net

RewriteEngine On
RewriteLog /etc/apache2/sites-enabled/rewrite_log.txt
RewriteRule ^dave\.html$ test.php [R]

DocumentRoot /var/www/ravenflight
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/ravenflight>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see
apache2's
# default start page (in /apache2-default) when you go
to /
#RedirectMatch ^/$ /apache2-default/
</Directory>

# ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
# <Directory "/usr/lib/cgi-bin">
# AllowOverride None
# Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Order allow,deny
# Allow from all
# </Directory>

ErrorLog /var/log/apache2/ravenflighterror.log

# Possible values include: debug, info, notice, warn, error,
crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ravenflightaccess.log combined
ServerSignature On

# Alias /doc/ "/usr/share/doc/"
# <Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
# </Directory>

</VirtualHost>

Davide Bianchi

2007-08-13, 1:26 pm

On 2007-08-13, IamDave <raven187@gmail.com> wrote:
> Okay, I did that and it said the syntax was ok. Also, the log file is
> showing up but nothing is being logged in it.


Ok, so the Rewrite module is loaded but for some reason the rewrite rule
never work.

><VirtualHost *>
> ServerAdmin dwill@ravenflight.net
> ServerName www.ravenflight.net
> ServerAlias ravenflight.net
>
> RewriteEngine On
> RewriteLog /etc/apache2/sites-enabled/rewrite_log.txt
> RewriteRule ^dave\.html$ test.php [R]


This will only work if your request begins with 'dave' without a '/',
maybe you need to add a '/' ?
RewriteRule ^/dave\.html$ /test.php [R]

> AllowOverride None


This will basically disable the .htaccess file

> #RedirectMatch ^/$ /apache2-default/


See? there is a '/'

Davide

--
I'm still waiting for the marketing slogan: Retry Reboot Reinstall Reformat
Redhat -- Alan
IamDave

2007-08-15, 1:22 am

Okay, I added the / and it still doesn't do anything. I'm really
confused. I'm certainly no expert but I can't see any reason why this
isn't working.
Dave

On Aug 13, 12:23 pm, Davide Bianchi <davideyeahs...@onlyforfun.net>
wrote:
> On 2007-08-13, IamDave <raven...@gmail.com> wrote:
>
>
> Ok, so the Rewrite module is loaded but for some reason the rewrite rule
> never work.
>
>
>
> This will only work if your request begins with 'dave' without a '/',
> maybe you need to add a '/' ?
> RewriteRule ^/dave\.html$ /test.php [R]
>
>
> This will basically disable the .htaccess file
>
>
> See? there is a '/'
>
> Davide
>
> --
> I'm still waiting for the marketing slogan: Retry Reboot Reinstall Reformat
> Redhat -- Alan


IamDave

2007-08-16, 7:27 pm

On Aug 15, 12:49 am, IamDave <raven...@gmail.com> wrote:[vbcol=seagreen]
> Okay, I added the / and it still doesn't do anything. I'm really
> confused. I'm certainly no expert but I can't see any reason why this
> isn't working.
> Dave
>
> On Aug 13, 12:23 pm, Davide Bianchi <davideyeahs...@onlyforfun.net>
> wrote:
>
>
>
>
>
>
>
>
>
>
>
>

Could there be something in apache.conf or some other configuration
file that's preventing this from working? Since you didn't see
anything wrong in with my vhost configuration I guess it has to be
somewhere else, right?
Dave

Davide Bianchi

2007-08-17, 1:21 am

On 2007-08-16, IamDave <raven187@gmail.com> wrote:
> Could there be something in apache.conf or some other configuration
> file that's preventing this from working?


Could be, but is kind of strange that you dong't get anything
in your log file about the rewrite. Try to post the entire config
file.

Davide

--
Best job interview question I've heard: "So, do you have
15 years of experience with Java?" "No, it just seems like 15 years...."
-- Geoff Lane
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com