how to edit document root of subdomain in bluehost CPanel - cpanel

Hope someone could help, am new to bluehost and had a shared hosting subscription. Now my issue is how to modify the subdomain document root.
example: from public_html/sub to public_html/sub/public
also when i created a subdomain it doesn't even allow me to add "/" unlike in godaddy
thanks.

I had the same issue, some how I landed to this URL
https://my.bluehost.com/cgi/dm/subdomain
and it allowed to to add "/" with subdomain, hope it helps

I found a solution so on the root folder add or edit if already existing .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.sub.domain.com$
RewriteCond %{REQUEST_URI} !sub/public/
RewriteRule (.*) /sub/public/$1 [L]
Done

In order to do this via the Bluehost interface, I followed these steps:
Go to 'My Domains' under 'Domains' in the left-hand column
Click the 'Manage' drop down and choose 'Unassign'
Click the green box that says 'Unassign'
Go to 'Assign' under 'Domains' in the left-hand column
Go to 'Subdomains' under 'Domains' in the left-hand column (If you don't click 'Assign first, then clicking 'Subdomains' takes you to a different page...)
Under the 'Existing Subdomains' header, find the subdomain with the Document Root you want to change and click the red trash can under 'Actions'
Now you can re-assign your domain as an addon or whatever and give it a new Document Root. (I should note, that none of these steps deleted my document root directory).
Go to 'Assign' under 'Domains' in the left-hand column
Follow the steps to assign an existing domain

Related

htaccess rewrites url on the address bar

I have a blog (not a Wordpress one, just a very simple html/css blog) on a hosting provider.
I recently moved my blog from the root folder to an internal folder /www/dist.
Since the blog has many referral links on the web, I'd want the url to my blog posts stay the same, as if I never moved the blog to that folder.
Let's take as an example one of my posts: "forza 4 in c".
Before moving the blog, here it was the url to access the blog post:
https://www.gianlucaghettini.net/forza-4-in-c
Right now, to access the same blog post, I have to go to:
https://www.gianlucaghettini.net/www/dist/forza-4-in-c
I want to keep the url the same, so:
https://www.gianlucaghettini.net/forza-4-in-c
To achieve that, that's how I configured the htaccess file on the root. Basically I'm telling apache to redirect all the requests to /www/dist.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^gianlucaghettini\.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.gianlucaghettini\.net$
RewriteCond %{REQUEST_URI} !www/dist/
RewriteRule (.*) /www/dist/$1 [L]
I hoped that wouldn't change the address bar but that's not the case, I can see the address bar with the extra /www/dist part on the url.
Now, shouldn't the RewriteRule suppose to keep the url the same? Why I see such behavior?
UPDATE
I'm being told by the hosting team that the url update happens on my pc only. I tried to open the link from different clients, even from a different ip address but I still see the url being updated.
UPDATE no.2
It looks like everything works fine if I add a final slash / to all the links. In this case the url in the address bar is not changed.

Checking for two cookies in an htaccess file, with an AND-statement

I have a little trouble configuring my htaccess-file, and i can't seem to find the right solution.
My project contains a folder with images (root/images), that i have protected with a htaccess file. The file checks for a certain cookie (e.g. cookie_root) and redirects the user if the value doesn't match the correct value (e.g. 12345).
RewriteCond %{HTTP_COOKIE} !cookie_root=12345
RewriteRule ^(.*)$ http://www.google.com [R,L]
My project also contains a subproject (root/subproject) with the same logic. It has it's own cookie (cookie_sub).
I would also like to access the root/images from within the subproject, so i would like to configure my htaccess file like the following : allow access if cookie_root is correct OR if cookie_sub is correct.
Can anyone point me in the right direction? Thanks in advance

Simple url masking via htaccess doesn't work

i'm trying to achieve the following:
I have domain.it and domain.fr
domain.it contains a website localized in multiple languages, so for example if you go to www.domain.it/fr/somecontent.php it shows that content in french language. This works. This website is hosted on a dedicated server.
In domain.fr i have an empty space with only an .htaccess. What i want is that when the user go to www.domain.fr/somecontent.php the browser shows the content from www.domain.it/fr/somecontent.php but keeping www.domain.fr/somecontent.php in the URL. So basically www.domain.fr/* should show the content from www.domain.it/fr/* but keeping www.domain.fr/* in the browser address bar.
Using an iframe is not an option because is not good for the SEO.
I'm using the following code inside the .htaccess on domain.fr (which is hosted on an OVH shared hosting):
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.fr$
RewriteRule ^(.*) https://www.domain.it/fr/$1 [P]
But when i open www.domain.fr or www.domain.fr/somecontent.php in the browser it says "Forbidden: You don't have permission to access /somecontent.php on this server."
Instead, if i place [L] or [L,R=302] in place of the [P] in the last line of .htaccess, it correctly redirect to the www.domain.it/fr/somecontent.php showing it contents, but it shows the destination url (the it domain) in the browser bar.
So i think the rules are correct, but for some reason when i use the [P] flag which as far as i know is needed to mask the url, it doesn't work.
Have you any clues ?
Thank you!

htaccess redirect folder to new domain index only

I have looked and looked and cant find the answer, I would greatly appreciate your help!!
I designed a website in a folder on a dummy domain, and forgot to add "noindex" and now its indexed, I need to redirect all pages in that folder to the index of the new domain.
example:
http: //dummysite/clientsfolder/
(I had to put space here because I can't post 2 links)
redirect to http://clientsnewdomain.com
all the code I have found redirects to http ://clientsnewdomain.com/clients folder, whether I place it in the /clientsfolder or the http://dummysite/
and then this results in a 404 page. Got into a mess here.
Also which is better to use to avoid this issue in the first place?
in
or a robots.txt?
Use that, in your /clientsfolder/.htaccess:
RewriteEngine on
RewriteRule ^(.*)$ http://clientsnewdomain.com/$1 [R=301,L]
OR in the root .htaccess:
RewriteRule ^clientsfolder/(.*)$ http://clientsnewdomain.com/$1 [NC,R=301,L]
The best place to avoid this issue in the first place is to use robots.txt.
But I prefer to use a folder protected by a password.

.htaccess point specific domain home to internal page

Okay...i am doing something kinda strange and out of the ordinary. I will try to explain...
I have several domain names pointed to the same root directory on my webserver. I can access the entire website using any of the domain names (I know this is bad for SEO, but there are reasons). Additionally, none of the "pages" really exist...as they are all being built dynamically...so i have some mod rewrite rules set up to point all incoming queries to view.php and passing in variables to generate the page content...anyway...
What i want to do is set ONLY THE HOME PAGE of two of my domains to (invisibly) use content of an existing sub page. Here is an example:
These all are the same page:
www.domain1.com/process/
www.domain2.com/process/
www.domain3.com/process/
which is really doing something like: view.php?page=process/
I want this page to display for www.domain2.com (and still also be accessible at domain2.com/process)
Essentially, there is a sub page of the site that i want to serve as the "HOME" page for domain2.com and domain3.com but if domain1.com should still use the default (index.php) HOME page.
I am sure i will need to post clarifications to this once replies start coming in...but here is what i have at the moment:
# special rules to set other domain names default homepage as specific internal page
RewriteCond %{HTTP_HOST} ^www.domain2.com [NC]
RewriteRule ^(.+)?$ /view.php?page=process/ [NC,L]
Currently this is sending ALL traffic to domain2.com to the "process/" page...so it is blocking out all other pages. I need to know how to have this rule ONLY apply to the base domain without any extra query string or url path. The key is that i DO NOT want to affect other pages within the domain...so i shoudl still be able to browse the whole site using this domain name...i just get started on a different view.
To only match the homepage, i.e. http://domain2com/ you need to match the empty path (as mod_Rewrite removes the leading /.
RewriteCond %{HTTP_HOST} ^www.domain2.com [NC]
RewriteRule ^$ /view.php?page=process/ [NC,L]