Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When serving content from a different domain without redirecting the browser (thus changing the URL in the address bar) one of two things needs to happen. Either there is a <strong>file-path</strong> resolution to the other domain, or a <a href="http://en.wikipedia.org/wiki/Reverse_proxy" rel="nofollow">reverse proxy</a> must be set up (and it's pretty easy to do if mod_proxy is loaded).</p> <p>It looks like you have your subdomain inside the document root of your main domain, which means this option will be viable. So if you want to it so when someone puts this URL in their address bar, <code>http://domain.com/page</code>, they get served the content in <a href="http://sub.domain.com/another-page" rel="nofollow">http://sub.domain.com/another-page</a>, you'd simply add these rules to the top of the htaccess file in the document root of your main domain (<code>public_html</code>):</p> <pre><code>RewriteEngine On RewriteRule ^page(.*)$ /subdomain_folder/another-page$1 [L] </code></pre> <p>Otherwise, the second option is to use mod_proxy:</p> <pre><code>RewriteEngine On RewriteRule ^page(.*)$ http://sub.domain.com/another-page$1 [L,P] </code></pre> <hr> <p>EDIT:</p> <blockquote> <p>I want to redirect some users, depending on their ip (geographic location) to another subdomain. And yes public_html is the root</p> </blockquote> <p>You can check against the IP via the <code>%{REMOTE_ADDR}</code> variable:</p> <pre><code>RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.89$ RewriteCond !^/subdomain_folder RewriteRule ^(.*)$ /subdomain_folder/$1 [L] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload