RewriteLog and RewriteLogLevel in MAMP - apache

I need to set my RewriteLogLevel in MAMP to figure out some mod_rewrite problems.
I put the below lines in my httpd.conf and my local .htaccess file, but I am not finding a output log. How do I set this up correctly?
RewriteLogLevel 9
RewriteLog "rewrite.log"

Try using a full path like /var/log/httpd/rewrite.log.
Also make sure you have mod_rewrite turned on.

Apache generally doesn't enable mod_rewrite by default, so you may need to add more entries to your httpd.conf file.
For instance, did you put in an entry for LoadModule that points to the mod_rewrite.so module?
Check this link for details:
http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/
Also, don't forget to restart Apache to test your changes.

Related

Apache mod_rewrite logging

I can't get mod_rewrite to log anything about what it's doing. You can imagine that this makes debugging mod_rewrite... challenging. I've followed the "instructions" at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html (I'm running 2.2.22 on a Mac), except that they're missing critical details like... which of the config files to put the configuration in, and in which level of XML elements.
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 8
Where do I put these directives so that I actually get logging about what mod_rewrite is doing? /tmp/rewrite.log is created, so Apache has some clue about what I want, but it logs nothing at all to this file.

Rewrite not working

I am absolutely lost, trying anything silly. Probably you know the situation. I tried hints from many threads here and on Google as well, but nothing helped. I have rewrite module loaded on my Apache (checked by phpinfo). For a site I have .htaccess created, where currently simple rule is stored:
RewriteEngine on
RewriteBase /
RewriteRule ^/certifikaty\.html$ certifikaty.php
So, I expect http://www.contech.cz/certifikaty.html will show http://www.contech.cz/certifikaty.php. Unfortunatly not. So, I set in my httpd.conf these lines:
RewriteLogLevel 9
RewriteLog "logs/rewrite.log"
The file (rewrite.log) is created, but it's empty even after server restart.
Please, could you help me to get out of this?
Marek
I found the solution - I had directive AllowOveride None in my httpd.conf. It means all httpd.conf are ignored ....

Clean URL's not working, mod_rewrite module installed

I just installed a fresh copy of Drupal 6.19 to get to speed on how to write modules. But for some reason the rewrite module isn't working for Drupal.
What I have checked:
$ apachectl -M >> it is installed
php_info() on current server >> says rewrite is installed also
I also double-checked the .htaccess file in my Drupal root folder
UPDATE: checked httpd.conf for AllowOverride All
I'm out options here. Looked everywhere but the Drupal settings aren't letting me to enable the settings and their test is simply visiting a site that should work if the rewrite module was there.
My specs:
Mac OS X 10.6 Snow Leopard
Using built-in Apache with PHP5
Thanks!
Last but not least, you must authorize your virtual host or directory to use .htaccess.
AllowOverride All
Update:
I can't figure out your exact problem but it's always worth testing that Apache is actually parsing your .htaccess file. Make a syntax error on purpose and see if you get a 500 Internal Server Error message. Also, test mod_rewrite with a simple redirection rule that doesn't involve Drupal.
Two more things to check:
Verify that your .htaccess is readable for your apache processes (Yes, I read that you double checked it, but did that include the file permissions?)
Enable rewrite logging - this might give you some hints on where it fails. Start with a log level of 5 and increase/decrease as needed. (Don't forget to turn it off again later, as it is a huge performance hog ;)
Also, I'd try to simplify the test scenario - start with a simple rewrite directive in a vhost configuration. Once that works, move it to a .htaccess in the top-level of the vhosts document root, then to sub directories (if needed/used).
Make sure that if the install is in a sub-directory that the username is part of the rewriteBase
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /~username/drupal**
If you running your Drupal installation in a sub-folder like: example.com/drupal, then enable "RewriteBase /" in your .htaccess file, it might help you.
A clean url could be something like www.example.com/fisherman instead of www.example.com/data/pages/fisherman.php
Some installations of apache have clean URL functionality out of the box. There are 2 steps that need to be configured correctly for it to work.
Enable rewrite module
Allow .htaccess file overrides
Both steps require SSH root access to your server. So if you are on shared host this probably won't work for you. Open your terminal:
Enable rewrite module
To enable the rewrite module, you can type the following command
sudo a2enmod rewrite
Now type
sudo service apache2 restart
to enable the changes. You can check if it’s working by typing
sudo apache2ctl –M
A list will appear. Look for “rewrite_module”.
http://codeontrack.com/enable-clean-urls-apache/
Look for this Line in your httpd.conf file
#LoadModule rewrite_module modules/mod_rewrite.so
If commented
Just uncomment it restart apache server then try enabling in drupal administer Clean URL Section
I added the following to my .htaccess file and it was solved. My problem was specifically hapening with Rackspace / CentOS image
Options -MultiViews
As Álvaro G. Vicario mentioned, the first thing to do is at the top of the .htaccess file add something like ghfdiddfdjf which should throw an internal error. If it doesn't, you know the .htaccess file isn't being read. Mine wasn't, and I found the following fix:
In the etc/apache2/sites-enabled folder, there was a file called default-000. It was in this file that I changed AllowOverride All in 2 places in the file.

RewriteLog triggers Internal Server Error

I am trying to do some debuging on my rewrite rules and wanted to enable RewriteLog to view how they are interpreted.
but when i activate it i get Internal Server Error
heres the line:
RewriteLog "/home/solomongaby/www/project/logs/rewrite.log"
thanks
The RewriteLog directive is only allowed in the server or virtual host configuration (see Context value).
You should post whole string from apache log file to be sure, but i suspect that you've tried to add this string in .htaccess and it gives you error "you can't have rewrite log directive here".
P.s. it's
RewriteLog "/home/solomongaby/www/project/logs/rewrite.log"
and not
RewriteLog "/home/solomongaby/www/project/logs/rewrite.log
Right?
It's most likely a permissions issue. Check Apache's error.log file.

Do you have to restart apache to make re-write rules in the .htaccess take effect?

I have pushed my .htaccess files to the production severs, but they don't work. Would a restart be the next step, or should I check something else.
A restart is not required for changes to .htaccess. Something else is wrong.
Make sure your .htaccess includes the statement
RewriteEngine on
which is required even if it's also present in httpd.conf. Also check that .htaccess is readable by the httpd process.
Check the error_log - it will tell you of any errors in .htaccess if it's being used.
Putting an intentional syntax error in .htaccess is a good check to make sure the file is being used -- you should get a 500 error on any page in the same directory.
Lastly, you can enable a rewrite log using commands like the following in your httpd.conf:
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
The log file thus generated will give you the gory detail of which rewrite rules matched and how they were handled.
No:
Apache allows for decentralized management of configuration via special files placed inside the web tree. The special files are usually called .htaccess, but any name can be specified in the AccessFileName directive... Since .htaccess files are read on every request, changes made in these files take immediate effect...
From the apache documentation:
Most commonly, the problem is that AllowOverride is not set such that your configuration directives are being honored. Make sure that you don't have a AllowOverride None in effect for the file scope in question. A good test for this is to put garbage in your .htaccess file and reload. If a server error is not generated, then you almost certainly have AllowOverride None in effect.
Only if you have not added the mod_rewrite module to Apache.
You only need to restart Apache if you change any Apache ".conf" files.
I have the same issue and it seems PiedPiper post about AllowOverride were most helpful. Check your httpd.conf file for "AllowOverride" and make sure it is set to All.
In case of .htaccess restart is not required if it is not working probable reasons include.
AllowOverride May not be set which user can set inside httpd.conf or might have to contact server admin.
Check the file name of .htaccess it should be .htaccess not htaccess.txt see here for guide how to create one.
Try to use Options -Indexes or deny all kind of simple directive to see if it is working or not.
clear browser cache everytime if having rule for redirects or similar if previous redirect is cached it appears as if things are not working.
What's in your .htaccess? RewriteRules? Check that mod_rewrite is installed and enabled.
Other stuff? Try setting AllowOverride to 'all' on that directory.