Main Tutorials

Mac OSX – Redirect .htaccess is not working ?

Here is the .htaccess file.

/Library/WebServer/Documents/.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mkyong/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mkyong/index.php [L]
</IfModule>

# END WordPress

Solution

Find the Apache config file in /etc/apache2/httpd.conf, make sure the following settings are configured properly :

1. The mod_rewrite.so is loaded.
2. In the Directory tag, update AllowOverride to all (default none)

sudo vim /etc/apache2/httpd.conf

# Make sure below module "mod_rewrite.so" is loaded.
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
#LoadModule perl_module libexec/apache2/mod_perl.so
LoadModule hfs_apple_module libexec/apache2/mod_hfs_apple.so

#...

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
    #...

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #...
</Directory>

References

  1. Apache – Mapping URLs to Filesystem Locations
  2. Apache HTTP Server Tutorial: .htaccess files

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Gomesh
3 years ago

Thanks. working for my Catalina os

Sohail Rahim
6 years ago

Thanks. This worked for me

Carol
6 years ago

Hi, is there any way to get the latest posts through e-mail?
joining an email subscription?
Thanks in advance