Forum Moderators: phranque
For some reason, my rewrite rules only work when placed in my httpd.conf, they seem to be ignored in my .htaccess file in my Apache Documentroot. I have AllowOverride set to all in my httpd.conf file, all other htaccess commands are picked up, including commands in that very file.
Here is the .htaccess file in question (located in my DocumentRoot):
Redirect /courses http://journalism.indiana.edu/academics/courses
There are several more of these.. these redirects work just fine. Later in the same file, the following is listed:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
RewriteRule ^/(admissionsnew¦admissionsnew/)$ /tech/wordpress/index.php?page_id=3
</IfModule>
The following:
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
Are lines created by OS X Server I have copied here. What do they do? Are they needed?
The key rewrite rule that is ignored is this:
RewriteRule ^/(admissionsnew¦admissionsnew/)$ /tech/wordpress/index.php?page_id=3
This same rule works in my httpd.conf file. I'd rather use htaccess files, as I plan to create more rules and don't want to have to restart the server after making these changes.
Thanks in advance for your help!
Welcome to WebmasterWorld!
Note that in a per-directory (.htaccess) context, the path to that directory location is stripped for security (and server-admin convenience) reasons. This is mentioned in the mod_rewrite documentation.
For example, a rule in httpd.conf might be written:
RewriteRule ^/fruit/apples/big_red.html http://www.example.com/fruit/apples/big-red [R=301,L]
RewriteRule ^apples/big_red.html http://www.example.com/fruit/apples/big-red [R=301,L]
RewriteRule ^big_red.html http://www.example.com/fruit/apples/big-red [R=301,L]
The rule pertaining to TRACE simply returns a 403-Forbidden response to any HTTP TRACE request.
Jim