Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST}!^(www\.example\.com)?$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule .* http://www.example.com/example/exampleaccount.form?account=%2 [P,L]
xoverride.example.com works fine and www.xoverride.example.com also, so no problems there! The problem however is when I click on some links on the site. I have for example a link on the site that makes a request to /createholiday.form . when I click this link I get the wrong page, i get exampleaccount.form . I don't know if anything is rewritten because if you are on xoverride.example.com, you can type everything you want, eg. xoverride.example.com/blabla.form , and you still would get the exampleaccount.form. Why is this?
When you don't use the xoverride.example.com, but you use the example.com?account=xoverride everything works fine. The funny thing is, when I click on createholiday.form from this url, a request is being made to /application/createholiday.form and not just /createholiday.form. (application is the name of the application).
I have a proxy configured for /example so everything that request a url preceeding with /example will be put through the proxy using AJP. This could be the reason the in the first scenario is works and the second it does not. But why is the second different? why is there not application in front of /createholiday.form. Is this because the url was already rewritten for the first time?
Anyway, can this issue be solved? Is there way to fix this, knowing that /createholiday.fom is requested, can we somehow rewrite this also?
We have createholiday.form but also createparty.form, and so on. All have 1 thing in common, they end with .form .
It is possible that there are some parameter behind e.g. createholiday.form?parameter=3&test=true , something like this could be rewritten to:
http://www.example.com/example/createholiday.form?parameter=3&test=true
What are your thoughts about:
- the difference between /application/createholiday.form and /createholiday.form
- my rewrite thoughts, can this be done? how?
For example, what is the purpose of the rule that you're having trouble with? The solution to your problem depends rather strongly on what you are trying to accomplish with that rule.
As shown, it will proxy any request for any resource (e.g. "page") in any subdomain except "www" to /example/exampleaccount.form?account=%2 in the canonical www.example.com domain.
So it's fairly obvious what the rule actually does, but not obvious what you really want it to do.
Jim
At this moment a request that's being made to for example xoverride.example.com is being rewritten to http://www.example.com/example/exampleaccount.form?account=xoverride. This is good.
I have some links on the webpage that will make a request to /createholiday.form /checkpics.do , /createparty.form?partyid=3 , and so on ... there are 3 different file extensions .form .do and .ajax
These links should also be rewritten, so the link:
/createparty.form?partyid=3 , should become
http://www.example.com/example/createparty.form?partyid=3
the same goes for /createholiday.form, /checkpics.do . etc...
If you only want URL-paths ending in .ajax, .do, and .form to be handled by this rule, then change the RewriteRule pattern to make it more specific. You may also need the first RewriteCond to prevent looping:
RewriteCond %{REQUEST_URI} !^/example/exampleaccount\.form$
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule \.(ajax¦do¦form)$ http://www.example.com/example/exampleaccount.form?account=%2 [P,L]
Jim
the link:
/createparty.form?partyid=3 , should become
http://www.example.com/example/createparty.form?partyid=3
In your example it will be rewritten to exampleaccount.form, right?
What do you think about this? Do you think this is correct?
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST}!^(www\.example\.com)?$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^(.+)$ http://www.example.com/example/$1 [P,L]
RewriteCond %{HTTP_HOST}!^(www\.example\.com)?$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ http://www.example.com/example/exampleaccount.form?account=%2 [P,L]
RewriteCOnd %{QUERY_STRING} !^account=
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com
RewriteRule ^([^.]+\.ajax¦do¦form)$ http://www.example.com/example/$1.form?account=%2 [P,L]
Jim