PDA

View Full Version : Problem with httpd.conf rewrite - Can you test??


tsmmos2
04-29-2008, 11:32 AM
I have some rewrite rules that are working fine on my Leopard Client Apache 2.2, but when I try to add the rewrite rules to my Leopard Server Apache 2.2, they don't work.

mod_rewrite is enabled and running and I am editing the proper httpd.conf file.

I am just using the default httpd.conf from /private/etc/apache2/ - I tried placing the rules at the very bottom and also in <IfModule mod_rewrite.c>
which didn't work. They did work in <Direcrory /> but it appended /Library/WebServer/Documents to the URL which gives an error.

Can somebody test these rules below in their Leopard Server httpd.conf file to see if they can get them to work?? Where is the proper place to add these rules?

RewriteEngine On
Options +FollowSymLinks
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301, L]
# Remove ".php"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.php(.*)\ HTTP
RewriteRule (.+)\.php(.*)$ $1$2 [R, L]]
# Remove ".asp"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.asp(.*)\ HTTP
RewriteRule (.+)\.asp(.*)$ $1$2 [R, L]]
# Remove ".aspx"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.aspx(.*)\ HTTP
RewriteRule (.+)\.aspx(.*)$ $1$2 [R, L]]
# Remove ".htm" and ".html"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.htm.*(.*)\ HTTP
RewriteRule (.+)\.htm.*(.*)$ $1$2 [R, L]]
# Remove ".cfm"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.cfm(.*)\ HTTP
RewriteRule (.+)\.cfm(.*)$ $1$2 [R, L]]
# Remove ".bak"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.bak(.*)\ HTTP
RewriteRule (.+)\.bak(.*)$ $1$2 [R, L]]
# Remove ".inc"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.inc(.*)\ HTTP
RewriteRule (.+)\.inc(.*)$ $1$2 [R, L]]
# Remove ".*"
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\..*(.*)\ HTTP
RewriteRule (.+)\..*(.*)$ $1$2 [R, L]]

hayne
04-29-2008, 11:52 AM
As I recall, there is a debugging option to ModRewrite. You should turn that on - it logs details about exactly what is happening at each step of the rewrite process.