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

WordPress "Pretty Permalink" mod_rewrite Rules

Why do all of my websites break when I add a mod_rewrite directive to an individual website's config file?


WordPress wants an .htaccess file in its website root to enable "pretty permalinks" (where "index.php?" and other query string params are not required in the URL.) WordPress provides the following apache config directives that it wants in this .htaccess file:


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


mod_rewrite is enabled in apache2.


I've read that enabling .htaccess files mean a "substantial performance penalty" so I don't want to use them since I'm trying to optimize the website to handle a high traffic spike. So, I added the directives above into the individual apache config file for the website, using vi in Terminal ssh connection.


When I stopped then started Web service via Server Admin, all of my websites fail to display. Thoughts?

Posted on Apr 20, 2011 2:58 PM

Reply
2 replies

Apr 20, 2011 3:14 PM in response to Ted Fitzpatrick

I found a way to test the Apache2 config files for syntax:


sudo apachectl -t


This reported:


Syntax error on line 11 of /etc/apache2/sites/mywebsite.conf:

RewriteBase: only valid in per-directory config files


So I deleted the RewriteBase directive and my websites still display. Fixed!


Now I need to configure WordPress (it lost its path to its "theme" resources) ...

Apr 21, 2011 2:29 PM in response to Ted Fitzpatrick

Actually, I needed to adjust the Rewrite code slightly. I found this excellent overview of the WordPress "pretty permalinks" mechanisms: http://wordpress.stackexchange.com/questions/994/setting-up-wordpress-with-custo m-permalinks-and-no-htaccess-file


To get things working the way I wanted, I needed to use the following in the conf file:


<Directory "/server/file/path/to/website/root/directory">

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</Directory>


... now to figure out if I can use some of the popular WordPress plugins without an .htaccess file ...

WordPress "Pretty Permalink" mod_rewrite Rules

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