0

First of all, I'm sorry if this question is pretty much a best practice question, rather than me asking for some help from you guys.

Basically, I'm new to webmaster stuff (as I am a web developer, but I've never had to manage domains / hosting before.

The way I usually work is with having the source code and the distribution code into two different folders, as some of my source gets compiled into the dist folder (some, not everything!)

I also use git as a source code tracker and then on the server I use git command line to push, pull switch branch and so on.

So, the problem I've got is that in git I have both folders (both dist and src) that get pushed.

Let me write down an example:

let's say I have a domain called www.mydomain.com

When I clone the repository into www.mydomain.com, the server root, if I navigate to the domain, above looks like this:

index of:
src/
dist/

and os to have the proper website, the URL needs to be www.mydomain.com/dist.

If I append dist at the end, it works, but I don't like it. I so tried to change the server document root in my Cpanel account from /domains/mydomain.com to /domains/mydomain.com/dist hoping that this would tell the website to look directly into the dist folder as a root document folder and not the level up.

That, unfortunately, didn't work.

I also tried with a redirect, but again, dist gets appended at the end of the URL.

I also started to look into git post-commit hooks, but I'm not sure that's the right path to follow.

Basically, after this very long question, all I'd like to know is a best practice to handle two folders pushed on the server with git, but having the URL point to one without having the URL to display the subfolder name. Is that possible? do I need to setup the .htaccess file to do that or is something that needs to be done when setting up the domain name?

Thanks for any suggestion

Nick
  • 13,493
  • 8
  • 51
  • 98
  • You are looking for a very basic rewrite rule. This is not really a programming question. It was a mistake to migrate it here. – tripleee Feb 07 '17 at 09:35
  • I have no idea who migrated it here to be fair as i know that's not a programming question – Nick Feb 07 '17 at 16:52
  • Possible duplicate of [.htaccess rewrite to redirect root URL to subdirectory](http://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory) – tripleee Feb 07 '17 at 17:12
  • Depends on the web server but at least that should give you some terminology to google. – tripleee Feb 07 '17 at 17:13
  • ok thanks i'll give it a go – Nick Feb 08 '17 at 07:37
  • I agree that it was a mistake to migrate this web-root question to stackoverflow. I suggest migrating this question to serverfault.com or perhaps returning it to webmasters.stackexchange.com . – David Cary Feb 08 '17 at 12:27
  • Nick, you probably need to edit some ".conf" file. What web server software are you using? If you are using Apache, this question is a duplicate of http://stackoverflow.com/questions/5891802/how-do-i-change-the-root-directory-of-an-apache-server . If you are using nginx, http://stackoverflow.com/questions/10674867/nginx-default-public-www-location answers your question. Or are you using something else? – David Cary Feb 08 '17 at 12:34
  • @DavidCary thanks for the comment. I'll have a look and let you know if it helped me :) and yes, I am using apache – Nick Feb 08 '17 at 12:36
  • just a quick thing: if I change the apache config file, it will change the root on all the server, right? not really on a per-folder basis...am I correct? I am happy with the default root directory being var/www, but each subdomain (or addon domains - basically all the domains hosted on my server) need to have a different root and not all the same one... – Nick Feb 08 '17 at 12:38
  • Nick, "How do I set up http.conf" sounds like an excellent question for http://serverfault.com/ , possibly using their "[apache2](http://serverfault.com/tags/apache2/info)" tag. ( "[Ask the user to create a new question after being asked in comments](http://meta.stackoverflow.com/questions/318267/ask-the-user-to-create-a-new-question-after-being-asked-in-comments)" ). – David Cary Feb 08 '17 at 13:37
  • ok, i'll post it there. Thanks – Nick Feb 08 '17 at 14:13
  • 1
    just as a cress reference: http://serverfault.com/questions/831341/apache-2-document-root-git-and-dist-src-folders – Nick Feb 08 '17 at 14:27

0 Answers0