Forum Moderators: phranque

Message Too Old, No Replies

htaccess rule suddenly stopped working

server upgraded, rule not working

         

Philosopher

6:27 pm on Jul 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok...first let me say I'm not htaccess expert, but after a good bit of trial and error and research I was able to get the below working about a year ago.

Basically, the rules rewrite calls such as

[subdomain.example.com...] --->http://www.example.com/script.php?c=subdomain
[subdomain.example.com...] --->http://www.example.com/script.php?c=subdomain&items=10
[subdomain.example.com...] --->http://www.example.com/script.php?c=subdomain&s=subdir
[subdomain.example.com...] --->http://www.example.com/script.php?c=subdomain&s=sub-dir&items=10

The odd thing is everything worked properly until my host did a recent server patch. Now, all the rules work except for the rule that rewrites [subdomain.example.com...] to http://www.example.com/script.php?c=subdomain

All the other rules work. Here are my rules

RewriteCond %{HTTP_HOST}!^www\.example\.net [NC]
RewriteCond %{HTTP_HOST}!^example\.net [NC]
RewriteCond %{REQUEST_URI} ([0-9]+)$
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
RewriteRule ^(.+)\.example\.net/([A-Za-z\-]+)/([0-9]+) test2.php?c=$1&s=$2&items=$3 [L]

The above rule works perfectly.

RewriteCond %{HTTP_HOST}!^www\.example\.net [NC]
RewriteCond %{HTTP_HOST}!^example\.net [NC]
RewriteCond %{REQUEST_URI} ^/([0-9]+)$
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.+)\.example\.net/([0-9]+) test2.php?c=$1&items=$2 [L]

Above works perfectly

RewriteCond %{HTTP_HOST}!^www\.example\.net [NC]
RewriteCond %{HTTP_HOST}!^example\.net [NC]
RewriteCond %{REQUEST_URI}!(.*)/([0-9]+)$ [NC]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
RewriteRule ^(.+)\.example\.net/(.+[^/])$ test2.php?c=$1&s=$2 [L]

Above works perfectly.

RewriteCond %{HTTP_HOST}!^www\.example\.net [NC]
RewriteCond %{HTTP_HOST}!^example\.net [NC]
RewriteCond %{REQUEST_FILENAME}!test2(.+) [NC]
RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
RewriteRule ^(.+)\.example\.net/ test2.php?c=$1 [L]

This rules doesn't.

Any idea as to what could be going wrong? My host knows that something in the patch has caused this, but is not being very helpful saying the patch was necessary...sorry.

jdMorgan

1:52 am on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this alternate version and see if anything changes:

RewriteCond %{REQUEST_URI} !/test2\.php [NC]
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^(.+)\.example\.net
RewriteRule .* /test2.php?c=%1 [L]

This should do the exact same thing, but uses REQUEST_URI instead of REQUEST_FILENAME and is also one line shorter.

Jim