[wp-hackers] Putting mod_rewrite rules in httpd.conf

Paul Menard codehooligans at codehooligans.com
Mon Sep 4 16:04:55 GMT 2006


I've tried and and it works. For the sake of example here is my  
actual Virtual Host entry. This is a local copy of WordPress pulled  
from Subversion this weekend. Fresh install.

During the setup I went through my normal configuration via Options - 
 > Permalinks. Once I have generated the .htaccess file I copied the  
contented into my httpd.conf and then removed the .htaccess file.

I'm not sure what happend to the Options -> Permalinks coding if you  
later attempt to update the .htaccess file.

<VirtualHost 127.0.0.1:80>
     ServerName dev.wpsvn.com
     ServerAdmin webmaster
     DocumentRoot 	/usr/local/htdocs/dev/dev.wpsvn.com
     ErrorLog 		/private/var/log/httpd/dev/dev.wpsvn.com/error_log
     CustomLog 		/private/var/log/httpd/dev/dev.wpsvn.com/access_log  
common
     <Directory 		/usr/local/htdocs/dev/dev.wpsvn.com>
         AllowOverride All
		# BEGIN WordPress
		<IfModule mod_rewrite.c>
			RewriteEngine On
			RewriteBase /wordpress/
			RewriteCond %{REQUEST_FILENAME} !-f
			RewriteCond %{REQUEST_FILENAME} !-d
			RewriteRule . /wordpress/index.php [L]
		</IfModule>
		# END WordPress

	</Directory>
</VirtualHost>



On Sep 4, 2006, at 10:46 AM, Scott Plumlee wrote:

> Computer Guru wrote:
>> On 9/1/06, Brian Layman <Brian at thecodecave.com> wrote:
>>> >>>somewhat related, is whether it would be possible to make WP
>>> >>> honor rules in httpd.conf versus using .htaccess files?
>>>
>>> Actually, as I understand it, WP will 'honor' everything you put  
>>> in either
>>> file (when they are active).  It has no choice.  WP has no idea  
>>> anything is
>>> happening until after the rewrite engine, wherever it is configured,
>>> releases the formatted request.
>>>
>>> So, in short, you can put the stuff anywhere you want it to be.   
>>> One thing
>>> though... In the newer versions of WP, all the rewrite rules say  
>>> to do is
>>> "If this doesn't point at a file, send it to WP.".  If your file  
>>> has more
>>> than those 9 or so lines total, then either it contains your own
>>> customizations or it is all legacy WP stuff.  The legacy WP stuff is
>>> redundant to what is now included in the WordPress PHP code.  For  
>>> the
>>> current version of WP, you just need:
>>> # BEGIN WordPress
>>> <IfModule mod_rewrite.c>
>>> RewriteEngine On
>>> RewriteBase /
>>> RewriteCond %{REQUEST_FILENAME} !-f
>>> RewriteCond %{REQUEST_FILENAME} !-d
>>> RewriteRule . /index.php [L]
>>> </IfModule>
>>> # END WordPress
>>>
>>> And all should work fine.
>>>
>>> >Anyone actually do this, or does everyone stick with .htaccess?
>>> It is an optimization to stick the rules in the conf file and set
>>> "AllowOverride None".  With "AllowOverride All" every request to  
>>> the server
>>> results in it repeatedly searching up the directory tree  
>>> for .htaccess
>>> files.  Any optimization that avoids disk access (even if it is  
>>> cached) is
>>> to be desired.  I would suspect many people put their stuff in  
>>> the .conf
>>> file and set it "AllowOverride None" making the server ignore any  
>>> and all
>>> .htaccess files.
>
> That's exactly what I was wondering about.  I'm going to try this  
> out and see.
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



More information about the wp-hackers mailing list