Yet another htaccess question


I am trying to set up a .htaccess file for my WordPress blog. I have searched a few websites to try to figure out how to create one, and to no surprise when I copy and paste codes in it and host the file I get an internal server error… I want to use permalinks on my blog. I am unsure of what I am doing wrong, or what it is I need to have to get my .htaccess file to work. My Apache version is: 2.2.13 (Unix), PHP version is: 5.2.*, and MySQL version is: 5.0.81-community.

Here is my code:

protect the htaccess file
<files .htaccess>
order allow,deny
deny from all

protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all

disable directory browsing
Options All -Indexes

protect from spam comments
RewriteEngine On
RewriteCond &#37;{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\\.php*
RewriteCond %{HTTP_REFERER} !.** [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Any help would be awesome!

The reason this doesn’t work is that you have comments mixed in with the code, but they’re not preceded by a hash (#) to show they’re comments, starting with the first line.

You don’t need to write the file yourself. If no .htaccess file is present, WordPress will create it for you when you set up permalinks from the dashboard. If WordPress doesn’t have write permission to the directory, it’ll provide you the text to copy/paste into the file.

Thanks Dan, I got it working and can begin skinning it! The website I had pulled the code from said to remove the ‘#’ from those lines so I guess that was what screwed me up. I had originally tried to let WordPress create the htaccess file but it never did, then it gave me the code to update it. I couldn’t figure out which directory to give the correct permissions to so that it could automatically write… Never been good on the server-side of the web, much better when it comes to designing websites.