2

I have a website with a shared hoster. There are a few things that I have there, like main site, Piwik, a blog and other standalone things.

Right now I have the following structure:

  • ~/subs/www gets served as example.org and www.example.org
  • ~/subs/blog gets served as blog.example.org
  • ~/subs/app/piwik gets served as app.example.org/piwik
  • ~/subs/app/foo gets served as app.example.org/foo

This is a all nice, I have separate cookies for the different applications. However, I would need a wildcard TLS certificate in order to get everything encrypted. Especially since Piwik is included in the main page, it must also be served over a secure connection. The provider wants 10 EUR/month for the wildcard certificate.

Now they offer one free certificate which I have issued for example.org and getting www.example.org for free. In consequence I would have to serve everything from example.org in order to get consistent TLS.

From a user standpoint, I would like to have the following URLs:

  • / is the main site
  • /blog is the blog
  • /app/piwik points to the Piwik installation
  • /app/foo points to some other stand-alone application

I do like the directory structure on the server, especially since I can just rsync --delete into the ~/subs/www directory and automatically prune files that I have deleted on disk. If I would upload the files such that they get served correctly, I would not do this any more.

So I would like to do this:

  • ~/subs/www is served at example.org/
  • ~/subs/blog is served at example.org/blog
  • ~/subs/app/piwik is served at example.org/app/piwik

From this question I gathered that the following .htaccess should do the trick:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/subs/
RewriteRule ^blog(.*) /subs/blog$1 [L]

However, when I request example.com/blog in my browser, I get redirected to example.com/subs/blog. I don't want to redirect, I want to do this mapping in the background such that the visitor will never see the URL fragment /subs/.

The shared hoster is Domain Factory, I can put in .htaccess files but I cannot alter any configuration files that need root access to the system.

How can achieve this?

5
  • The document root is ~/subs/www for the main site and the others are configured as separate virtual hosts. Commented Aug 19, 2017 at 9:18
  • Can you edit your virtual host configuration files? You could do this with Alias directives, but they can only be used in the main conf files, not in .htaccess. Commented Aug 19, 2017 at 9:20
  • @StephenOstermiller: I have looked into the admin panel, and I cannot find anything. I think I am limited to .htaccess. Commented Aug 19, 2017 at 11:52
  • Then your only solution is probably to move the directories. Commented Aug 19, 2017 at 13:21
  • If I was to use symlinks, I'd have to symlink every top-level file and directory from the “subdomains”, right? Commented Aug 19, 2017 at 18:13

1 Answer 1

1

From what i gather, try this :

RewriteRule ^blog$ /subs/blog [L]

and save it in your roots (www) folder's .htaccess

But i believe that your best bet would be to do a direct redirection such as

Options +FollowSymLinks
Redirect ~/subs/blog/ http://www.yourdomain.com/blog/$1
3
  • using this technique will mask the /subs/ folder from the url. Check out both these sites links and see them in action miyustory.com and miyustory.com/v5/index.php both these links are identical however the first one masks the entire url to point it to the main page and the other is the actual link that i try to keep hidden this was done using the technique i posted as your answer. Try it Commented Aug 26, 2017 at 16:14
  • 1
    Please do not use this site to promote yours
    – John Conde
    Commented Aug 26, 2017 at 18:18
  • Please note that with these links, I am not trying to promote anything. It just happens to be information about this topic in question. Very useful and informative information about this topic can be located at those links Commented Aug 26, 2017 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.