Forum Moderators: phranque
I've been trying to find out what this PHP version tracker is, but searching on google haven't given me any answers - except other people wondering the same.
Any information would be of help.
My guess is that there are some people that are checking domains for what version of php is running, in order to do exploits.
My other question is how I can rewrite this so that I don't have to write the same RewriteCond for every RewriteRule....?
---
RewriteCond %{HTTP_HOST}!www\.domain\.com$
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^$ domain2/index.html [L] #index file
RewriteCond %{HTTP_HOST}!www\.domain\.com$
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.+)/ $domain2/$1/index.html [L] #subfolders
RewriteCond %{HTTP_HOST}!www\.domain\.com$
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.+)$ domain2/$1 [L] #subfiles
I'm using a webhotell with a dedicated IP to handle many domains. This code just redirect to another folder, but I want to do this with as few lines as possible.
Cheers
Lars
Before getting into methods to compact this, code, we need to understand its purpose clearly.
RewriteCond %{HTTP_HOST}!www\.domain\.com$
RewriteCond %{HTTP_HOST} domain2\.com$
Actually is that first line not necessary. I put it there for debugging, making sure that no rewrite is being done on that www.domain.com domain..
So, it should look like this:
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^$ domain2/index.html [L] #index file
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.+)/$ domain2/$1/index.html [L] #subfolders
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.+)$ domain2/$1 [L] #subfiles
And I want to reduce it to something like this, but so that all RewriteCond is valid for all the rules:
RewriteCond %{HTTP_HOST} domain2\.com$
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^$ domain2/index.html [L] #index file
RewriteRule (.+)/$ domain2/$1/index.html [L] #subfolders
RewriteRule (.+)$ domain2/$1 [L] #subfiles
Is that possible by adding [C] or something similar?
The easiest way to 'share' RewriteConds is to take the opposite sense of the conditions, and skip the rules, instead of executing them.
Also, if you test for HTTP_HOST=SomeDomain, then there is no need to test for HTTP_HOST NOT=SomeOtherDomain.
Do not end-anchor domains. Otherwise, a browser or user appending a port number (domain.com:80) will break the rule.
Comments must be on a separate line. Otherwise, they may cause error warnings, fill up your error log, and slow down your server.
Given all that, you could use something like this:
# If request is not to domain2 or file exists, skip next three rules
RewriteCond %{HTTP_HOST} !domain2\.com [NC,OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [S=3]
#
# Index
RewriteRule ^$ /domain2/index.html [L]
# Subfolders
RewriteRule ^(.+)/$ /domain2/$1/index.html [L]
# Subfiles
RewriteRule ^(.+)$ /domain2/$1 [L]