Forum Moderators: phranque
[subdomain.example.com...] to /page1.htm
[subdomain.example.com...] to /page2.htm
[subdomain.example.com...] to /page3.htm
[subdomain2.example.com...] to /page1.htm
[subdomain2.example.com...] to /page2.htm
[subdomain2.example.com...] to /page3.htm
I have gotten the initial rewrite workin with the following:
RewriteCond %{HTTP_HOST} ^(.*)(subdomain)(.*)\.example\.com
RewriteRule ^(.+) %{HTTP_HOST} [NC]
RewriteRule ^(.*)(subdomain)(.*)\.example\.com(.*) page1.htm [L]
But the URL [subdomain.example.com...] seems to also go to /page1.htm rather than /page2.htm as does all the others. How do I ensure that the pages in the subdomain don't all go to /page1.htm?
Thanks
[edited by: jdMorgan at 12:12 pm (utc) on June 18, 2009]
[edit reason] example.com [/edit]
If you are willing to rewrite subdomain "apple" to page "page_apple", so that the page name is derived from the subdomain name, then one rule can be used:
RewriteCond $1 !^page_
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule ^ /page_%1.html [L]
Be aware that as you have requested, *all* URL-paths in your subdomains will be rewritten to an HTML page. You should reconsider this plan, since all image requests, requests for robots.txt and sitemap.xml files --everything-- will be rewritten to this HTML page.
In order to rewrite only the 'root' of each subdomain, change the rule pattern from "^" to "^$".
Jim
ie
[france.mysite.com...]
must go to [mysite.com...]
[france.mysite.com...]
must go to [mysite.com...]
[france.mysite.com...]
must go to [mysite.com...]
[italy.mysite.com...]
must go to [mysite.com...]
I just need to be able to rewrite these to go to the contentpage.php with whatever id I specify. Is this possible? I understand I may need to write lots of seperate rewrite rules for all of these.
Thanks again for the help.
RewriteCond %{HTTP_HOST} ^france\.example\.com
RewriteRule ^myrandompagename\.htm$ /contentpage.php?id=1 [L]
...
RewriteCond %{HTTP_HOST} ^italy\.example\.com
RewriteRule ^myrandompagename\.htm$ /contentpage.php?id=4 [L]
For example, you could easily use a URL like "art-3-myrandompagename.htm". The only requirements are that the id number be in a fixed position in the URL, that that id number be distinguishable from the "randompagename" part of the URL (done here using the first and second hyphen), and that URLs which need to be rewritten are easy to distinguish from those which must not be rewritten(done here with the "(art)icle" tag at the beginning of the URL).
Both the URL format and the "art" tag shown here in this example are arbitrary and not required; Only the three requirements listed above must be met.
Jim