Apache, mod_rewrite on Mac OS X

Here a quick list of things to remember when trying to debug Apache on Mac OS X (10.4.8 anyway):

Apache

Command line control of Apache:

  • “sudo apachectl start ” – to start the Apache process
  • “sudo apachectl stop” – to stop the Apache process
  • “sudo apachectl restart” – to restart the Apache process

Folders to find Apaches config files (In the Finder press Command + Shift + g):

  • “/var/log/httpd/” – where to look for Apaches error log. Check if having problems starting and stopping the httpd process (apache that is). You want to be looking at the ‘error_log’ file in a text editor and the very end of the file.
  • “/private/etc/httpd/” – the location of the apache config files. also looking the sub folder ‘/users’ for configuring virtual host names for your machine

Mod Rewrite

You’ll have to enable .htaccess if you want touse the mod_rewrite in those files. edit /private/etc/httpd/httpd.conf to get this happening. Also need to edit the .conf in the users folder (/private/etc/httpd/users/) for your user account.

The minimum require lines, without the rewrite rules, are:


# This is required for every directory that you want to use
# mod_rewrite in even if its stated in the httpd.conf
RewriteEngine on

# Modify the RewriteBase if you are using a subdirectory.
# This is relative to the web root for this virtual host NOT
# the main web root.

RewriteBase /
...

57 thoughts on “Apache, mod_rewrite on Mac OS X”

Comments are closed.