-1

My domain mainsite.com is actual pointed to /public_html/ .

But i want to point it to sub-site like /public_html/subsite .

So i tried this :

RewriteCond %{HTTP_HOST} ^(www\.)?mainsite\.com$ [NC]
RewriteRule !^(subsite) /subsite%{REQUEST_URI} [L,NC]

It working fine .

Now 2nd is i have many sub-site/sub-folder under /public_html/subsite like /public_html/subsite/(site1 or others...) .

But when i type mainsite.com/(site1 or others...) then it showing me this url mainsite.com/subsite/(site1 or others...) which i don't want.

I want to hide only /subsite/ from url when user browse.

Debar
  • 11
  • 1
  • 6
  • Your question isn't clear. Do you want to redirect the web browser to the new URL, or do you want to keep the web browser showing the original URL but show the content from a different path? Or something else? – Tim Sep 20 '16 at 19:19
  • Ok I updated.... @Tim – Debar Sep 20 '16 at 19:23
  • Possible duplicate of [Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod\_Rewrite Rules but Were Afraid to Ask](http://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever) – Unbeliever Sep 20 '16 at 19:28
  • When someone browse `www.mydomain.com/error/` this url, which actual path is `www.mydomain.com/site1/error/` so i want to hide `/site1/` wihout changing url. – Debar Sep 20 '16 at 19:30
  • Your question makes no sense to me. – Tim Sep 20 '16 at 19:35
  • @Debar You should clarify your question a bit. Start by adding what you said in your last comment (I think). – Ryan Babchishin Sep 20 '16 at 19:38
  • Your second rewrite rule says if it doesn't have subsite in the URL.. redirect to it. If that's not the behavior you want, why put the rule in? –  Sep 20 '16 at 20:50
  • Ok can you understand my question what i want? If you understand please give a example how to fix it. – Debar Sep 20 '16 at 21:00
  • Do you have multiple domains? It's not clear why your rule is triggering an _external redirect_ (ie. the URL is changing) - the rule you have posted is an _internal rewrite_. Clear your browser cache to make sure no erroneous redirects have been cached. – MrWhite Sep 20 '16 at 22:56
  • Yes i have multiple domain for same hosting account. But i want to show different for each domain using htaccess. – Debar Sep 21 '16 at 06:17

1 Answers1

2

Read this info about setting up an alias:

https://httpd.apache.org/docs/current/mod/mod_alias.html

The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with URL-path will be mapped to local files beginning with directory-path. The URL-path is case-sensitive, even on case-insensitive file systems.

Alias "/image" "/ftp/pub/image" 

A request for http://example.com/image/foo.gif would cause the server to return the file /ftp/pub/image/foo.gif. Only complete path segments are matched, so the above alias would not match a request for http://example.com/imagefoo.gif. For more complex matching using regular expressions, see the AliasMatch directive.

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36