Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite .htacces VS httpd.conf

got it working in

         

summerg

10:39 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Hi All -

I've been reading up on mod-rewrite and have several rules working currently via my .htaccess file. Now I'd like to add a RewriteMap but understand that they must go in my httpd.conf file. I've tried moving my current rules to httpd.conf but they are not working. Here's what my htttpd.conf file looks like to date:

DocumentRoot "/data/www/root/"
#
<Directory />
Options +FollowSymLinks +Includes
AllowOverride None
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^products/singleboard(/?)$ /products/singleboard.php
RewriteRule ^singleboardcomputer(/?)$ /products/singleboard [R]
RewriteRule ^products/iocomm(/?)$ /products/iocomm.php
RewriteRule ^products/([0-9]+)(/?)$ /products/detail.php?ProductID=$1
</IfModule>
</Directory>

Is this the right location in the conf file for Rewrite Rules? We don't have any Vhosts so I can't add it in at that level.

thanks
summer

jdMorgan

11:15 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



summerg,

Welcome to WebmasterWorld [webmasterworld.com]!

There's a subtle but important difference between RewriteRules in .htaccess and httpd.conf, which has to do with the 'form' of the URL that RewriteRules 'see'.

In .htaccess, you might write:

RewriteRule ^products\.html$ /new_products.html [L]

whereas in httpd.conf, you must write:

RewriteRule [b]^/p[/b]roducts\.html$ /new_products.html [L]

This is described by example in the mod_rewrite documentation, but it's quite subtle. Why it's doen this way, I'll never know -- It certainly adds unneccessary complication to the process you're engaged in. (And yes, RewriteMap only works in httpd.conf, and your code location looks fine.)

Jim

summerg

7:59 pm on Jan 5, 2004 (gmt 0)

10+ Year Member



thanks! That helped a bunch.