SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Feb 26, 2004, 19:36 #1
- Join Date
- May 2003
- Posts
- 595
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Three domains, same website and mod_rewrite
Hi,
We have three domains, all on the same website (same server), and need to use mod_rewrite so that when a user has this in the (address) browser bar:
http://example1.com
the mod_rewrite will actually let the user see the contents of
http://example1.com/shop1
This needs to happen for the 3 domains (which are actually seperate 'stores' or 'shops', but share the same database - osCommerce). Therefore, if any user has the following in the browser bar, the mod_rewrite will do this:
http://example1.com ---mod_rewrite--> http://example1.com/shop1
http://example2.com ---mod_rewrite--> http://example1.com/shop2
http://example3.com ---mod_rewrite--> http://example1.com/shop3
We would not want the browser bar URL to change, in fact the default file is 'index.php', so when they visit:
http://example1.com/index.php
they will _really_ be at:
http://example1.com/shop1/index.php
Hope that makes sense.
There is another minor matter, and I assume it is best dealt with by "mod_rewrite". We only want people to visit the site, using any of the 3 domain names. They could, if they knew some other details, get to the site like this:
http://IP.add.re.ss/~username
OR
http://webserver_name/~username
because we have PHP code to check for domain name only, if anyone attempts access like that described above, we would like a "404" page displayed, or similar, informing them of the error.
Thanks,
Peter
-
Mar 3, 2004, 19:22 #2
- Join Date
- May 2003
- Posts
- 595
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
Therefore, if any user has the following in the browser bar, the mod_rewrite will do this:
http://example1.com ---mod_rewrite--> http://example1.com/shop1
http://example2.com ---mod_rewrite--> http://example1.com/shop2
http://example3.com ---mod_rewrite--> http://example1.com/shop3
Code:RewriteEngine on RewriteCond %{REMOTE_HOST} !^.+\.example1\.com$ RewriteRule ^(/~.+) http://example1.com/shop1/$1 [R,L]
Peter
-
Mar 4, 2004, 01:13 #3
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry Peter for the delay but I'm really busy these weeks.
You need to use this rules:
/.htaccess
Code:Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com$ [NC] RewriteRule !^shop1/.*$ /shop1%{REQUEST_URI} [NC,L] RewriteCond %{HTTP_HOST} ^(www\.)?example2\.com$ [NC] RewriteRule !^shop2/.*$ /shop2%{REQUEST_URI} [NC,L] RewriteCond %{HTTP_HOST} ^(www\.)?example3\.com$ [NC] RewriteRule !^shop3/.*$ /shop3%{REQUEST_URI} [NC,L]
www.example1.com would go under www.example1.com/shop1/
www.example1.com/pippo.gif would go under www.example1.com/shop1/pippo.gif
www.example1.com/path/to/pippo.php would go under www.example1.com/shop1/path/to/pippo.php
Same Juice for example1, and exampl2.
Is it what you were looking for ?
Let me know.
After that is okay we will take a look at your other questions.
Thanks,
-
Mar 4, 2004, 04:22 #4
- Join Date
- May 2003
- Posts
- 595
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi pippo,
Sorry to hear you are so busy, ..... hope you take it easy, and can take a break soon.
Originally Posted by pippo
Code:RewriteCond %{HTTP_HOST} ^(www\.)?example1\com\.au$ [NC]
Code:RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com\.au$ [NC]
.htaccess
Code:Options +FollowSymLinks RewriteEngine On # rewrite base to make sure it is in the public_html path RewriteBase / # Check that it's 443 port RewriteCond %{SERVER_PORT} ^443$ # Make proxy redirection RewriteRule ^someotherdomain.com.au/order-form\.php$ /~username/order-form.php # rule for all GIF files RewriteRule ^someotherdomain.com.au/images/([^.]+\.gif)$ /~username/images/$1
example1.com.au
example2.com.au
example3.com.au
... just thought I should mention that there is already a rewrite condtion and rule, but it is definitely for another domain, to handle a shared HTTPS connection. I just needed to be sure that there would be no conflicts. The way I'm trying to understand mod_rewrite "conditions" and "rules", is that if the condition is true, all the following rules will apply, until another condition command ( RewriteCond) is evaluated. They act like a 'set' I guess.
Btw, I don't remember putting this in .htaccess, maybe CPanel did it ? Can you please explain what this code does.
Code:<Files 403.shtml> order allow,deny allow from all </Files>
Thanks for all your help,
Peter
-
Mar 7, 2004, 03:37 #5
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
a)
> RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com\.au$ [NC]
THat's correct.
\. means ``dot''
The dot had to be escaped, by adding the ``\'', because regular expressions will consider ``.'' as ``every character''.
Some examples:
example1\.com\.au
will only match example1.com.au
example1.com.au
will match
example1.com.au
example1Acom.au
example1.comBau
example1AcomBau
example1.comUau
example1.comZau
so on...
b)
Yes, the old rules should not be in conflict with the new ones...
> The way I'm trying to understand mod_rewrite "conditions" and "rules",
> is that if the condition is true, all the following rules will apply, until another
> condition command ( RewriteCond) is evaluated. They act like a 'set' I guess.
An example should make it clear:
RewriteCond something george
RewriteRule do_something
RewriteCond something_other strait
RewriteRule do_something_other
is like to write:
if (something == george) {
do_something();
}
if (something_other == strait) {
do_something_other();
}
c)
<Files 403.shtml>
order allow,deny
allow from all
</Files>
But in pratice it says:
A 403.shtml can be accessed
So if in some directory you have denied all accesses doing the previous staff you can access all 403.shtml from there.
I have to say that I don't know CPanel, never used a control panel in my life...I'm an old-text-coder guys...lol
Hope It Really Helped
Andrea
-
Mar 7, 2004, 06:12 #6
- Join Date
- May 2003
- Posts
- 595
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi pippo,
Originally Posted by pippo
Originally Posted by pippo
Originally Posted by jehoshua
Originally Posted by pippo
Originally Posted by pippo
Thanks for all your help, you are a good tutor.
Peter
Bookmarks