Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

.htaccess causes 403 error

I have been trying to enable .htaccess on my localhost for a while. I have found the info about changing AllowOverride to "All" for both /etc/apache2/httpd.conf and /etc/apache2/users/username.conf.

Whenever I change the .htaccess file in the directory where I am serving a local version of the site, suddenly all I get is Error 403. I delete all the directives in .htaccess and the site is back.

The .htaccess directives were put there by Wordpress Dashboard so I doubt it was a typo on my part. Mod_rewrite does seem to be enabled in the .conf files. This is what the file said:

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

\# END WordPress

Could this be related to some other file in the system that need to be changed? File permissions?

I'm an Apache newb so please answer in English.

MacBook Pro, Mac OS X (10.5.8)

Posted on Feb 14, 2010 8:29 PM

Reply
5 replies

Feb 14, 2010 10:22 PM in response to gmdavis

Hi--

Welcome to the Apple Discussions.

gmdavis wrote:
Whenever I change the .htaccess file in the directory where I am serving a local version of the site, suddenly all I get is Error 403. I delete all the directives in .htaccess and the site is back.


What does the Apache error log say when this happens? Look at it in the Console app from your Utilities folder. The path to the error log is /var/log/apache2/error_log. Post the errors here if they don't make sense to you.

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

\# END WordPress


That looks relatively reasonable, though Rewrite rules can be a little tricky. Where in the WordPress Dashboard did you get this? I looked and I can't find anything like it in mine (WP 2.9). It looks like all these rules are doing is redirecting any requests for files or directories that don't exist right back to the main WordPress index page. But I don't see anything like it in my dashboard.

One thing that comes to mind: "username" isn't really what's in the actual file, right? Unless your actual short username for the account where this is hosted is "username", that would cause a problem. That should be the actual short user name, assuming it's hosted in the user's Sites folder.

charlie

Feb 15, 2010 5:28 AM in response to Charles Minow

Thanks for the reply Charlie. I didn't know about the Console. That's a very useful tool!

Here is an error that looks promising:
[Sun Feb 14 22:06:58 2010] [error] [client ::1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/garydavis/Sites/wordpress/, referer: http://localhost/~garydavis/wordpress/wp-admin/options-permalink.php

The wordpress setting is in Dashboard/settings/permalinks. Changing from anything but the "default" will add a redirect to .htaccess

Anyway, I could use some guidance in what that error exactly implies. I assume if I go into the config files and look for FollowSymLinks. But, I have to go to work now. I'll try this tonight. Any ideas until then are appreciated.

Feb 15, 2010 7:51 AM in response to gmdavis

Hi--

gmdavis wrote:
Thanks for the reply Charlie. I didn't know about the Console. That's a very useful tool!


Yeah, the Console is very, very handy. And the Apache logs are often very, very helpful with their error messages.

Here is an error that looks promising:
[Sun Feb 14 22:06:58 2010] [error] [client ::1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/garydavis/Sites/wordpress/, referer: http://localhost/~garydavis/wordpress/wp-admin/options-permalink.php

The wordpress setting is in Dashboard/settings/permalinks. Changing from anything but the "default" will add a redirect to .htaccess


Ah, I see what's going on. Basically the log entry is telling you that you have to allow Apache to follow symbolic links in order to turn on URL rewriting. Since you're hosting this in your user's Sites folder, just open the /etc/apache2/usrs/username.conf file and add FollowSymLinks to the Options line:

{code}Options Indexes MultiViews FollowSymLinks

Stop and restart Personal Web Sharing, and it should work now. If you want to read about URL rewriting, there's a pretty intense section on it at the Apache web site. But it's a pretty complex subject, so don't feel bad if it seems a bit difficult.

charlie

.htaccess causes 403 error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.