Telling ftpsync to ignore directories in public_html - node.js

In ftpsync, when I try to update my site example.com, I find ftpsync deletes everything in public_html (where example.com resides). My host specifies that other domains reside as subdirectories in public_html.
Even though I have tried telling ftpsync to ignore public_html/subdir-example1.com and the code shown below it gets removed every time I try an update.
{
"local":"public/",
"remote":"public_html/",
"host":"example.com",
"port":21,
"user":"secret",
"pass":"secret",
"connections":"1",
"ignore":[
".htaccess",
"subdir-example1.com/",
"subdir-example2.com/"
]
}
So how do I tell ftpsync to ignore a directory on the host?

ftpsync says it basically nukes the entire directory on the other server. So the workaround is to create a subdirectory in public_html, then change the remote in config.json to be public_html/subdirectory/maindomain.com
Then change .htaccess following instructions written by BlueHost:
# BlueHost.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]
https://my.bluehost.com/cgi/help/347#redirect

Related

htaccess configuration directories for subdomains and root domain

My folders in my www directory as set up as follows:
www/forums
www/helpdesk
www/www
In the base www folder (not www/www), I have the following set up in my htaccess file to redirect based on subdirectory
# Direct subdomains to appropriate folder in WWW directory
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
I also have the following set up for configuring the index.php on the main site (www.example.com) - this is also in the htaccess file in the www directory:
# Rewrite rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ www/$1 [L,QSA]
The problem I am facing is that I have stuff from forums.example.com that I want to embed in www.example.com (Vanilla Forums + WordPress plugin) - if I configure this using the admin panels, the iFrame gets blocked because they are different domains.
I found out that when I go to www.example.com/forums, I get the same front page as forums.examples.com - but all the clean URLs break.
When I look at the .htaccess file in the www/forums folder, I see the following configuration
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
What do I need to do to the .htaccess file in the www directory so that when I go to www.example.com/forums, it works the same as if I went to forums.example.com
...the following set up in my htaccess file to redirect based on subdirectory
# Direct subdomains to appropriate folder in WWW directory
Aside: That snippet is just a canonical non-www to www redirect. It doesn't "redirect based on subdirectory" nor does it "direct [any] subdomains". (?)
the iFrame gets blocked because they are different domains.
It sounds as if you need to set an Access-Control-Allow-Origin HTTP response header on forums.example.com to allow the content to be "embedded" in example.com? Something like the following (using mod_headers) in the www/forums/.htaccess file:
Header set Access-Control-Allow-Origin "http://example.com"
What do I need to do to the .htaccess file in the www directory so that when I go to www.example.com/forums, it works the same as if I went to forums.example.com.
How do "all the clean URLs break"? However, given the HTTP header mentioned above, you shouldn't have to do anything more and still access forums.example.com (not the subdirectory).
Incidentally, the fact you can access the subdirectory (that the subdomain points to) is just how your hosting is configured. Normally you should block access to the subdirectory in order to prevent duplicate content issues (and any other issues, such as the linking problem you mention).
Also note, that due to the way mod_rewrite directives are inherited (or not in this case). The mod_rewrite directives in the www/forums/.htaccess file completely override the mod_rewrite directives in the parent folder.

How to setup virtual directories with .htaccess

I'm trying to setup virtual directories with .htaccess.
I want to use this directories as language indicators. E.g. example.com/de-de, example-com/de-en and so on. But in fact, the directories doesn't exist on the server and the index.html file at the root of the directory should be loaded. I wrote some rules, but they dont work properly:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
URLs like example.com/de-de works, but example.com/de-de/ doesn't. When I open example.com/de-de/ it tries to load resources from the /de-de/ subdirectory, e.g. de-de/js/jquery.js instead of /js/jquery.js. Whats wrong with my rules? And is there a way to force a trailing slash, so users will be redirected from example.com/de-de to example.com/de-de/?

.htaccess rewrite and subdomains connected to subdirectories

I have installed wordpress to my public_html/ folder on my host. Now, I want to help my friend to get his own wp blog. I wanted to add a folder public_html/zoran/ where I wanted to install another wp and to add subdomain zoran.example.com to call that folder.
Problem is that .htaccess from public_html/ (my wp installation) is messing .htaccess inside public_html/zoran/ folder. I googled a lot, and figured out that this is impossible to have one .htaccess rules in root folder and other in subfolder (mod rewrite).
I cannot access my cPanel for couple of days now, and it will be unavailable for a few days, I recieved mail about that.
Now, I am at this point. I have moved my wp into public_html/www/ and I stored .htaccess file into public_html/ with following content:
# Rewriting conditions
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*) http://www.example.com/ [R,L]
# Identify subdomain as %1
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
# Check if %1 is directory
RewriteCond %1 !-d
# rewrite the request to the subdomain's subfolder
RewriteRule (.*) %1/$1 [L]
Above code redirects example.com to www.example.com, and also, it opens my wp, stored in public_html/www/. But, when I try to go to zoran.example.com, I get 500 error, and that folder has just index.html file in it.
What is happening? How come that www folder works, and folder zoran does not work on same principle?!

Load new site from subdirectory as index

I want to load my new website from subdirectory including default index.html page.
In my public_html, I have /oldsite/ and /newsite/ folders...
Then.. When I access to http://www.mysite.com/.. i want it to load all contents from http://www.mysite.com/newsite/ without redirecting. I want to do it with .htaccess mod_rewrite if possible..
Can anybody help me out with this. How to do this?
# to ensure that server already know that you going to use mod-rewrite
RewriteEngine on
# if the request from http is mysite.com or www.mysite.com go to next line (else abort)
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ [NC]
# if the request destination is not the folder /newsite go to next line
RewriteCond %{REQUEST_URI} !^/newsite/
# if the requested name is not an existed file in public_html directory
RewriteCond %{REQUEST_FILENAME} !-f
# if the requested name is not an existed directory in public_html directory
RewriteCond %{REQUEST_FILENAME} !-d
# forward request to /newsite/
RewriteRule ^(.*)$ /newsite/$1
# if the request domain is mysite.com (with out any string afterward), go to next line
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$ [NC]
# forward request to the default file under newsite directory
RewriteRule ^(/)?$ newsite/ [L]
It is generally not a good idea to deploy a website like this. Instead you should create virtual hosts for the live and development versions of your site. If you can't do that with your current hosting provider you can make use of symlink for public_html and when the new version is ready to go live just change its path. Hope that helps.

domain is redirected to suddirectory by mod_rewrite but cakePHP is messing up urls

I currently have my main domain being redirected from the root directory to a subdirectory. And because of this every time I use cakePHP to write urls or get the current one it displays the subdirectory.
for example:
If I am at the home page (http://example.com) and then use cake's $this->url it will return /mysubdirectory/
here is the .htaccess file I used (of course modified to fit my needs) in my root directory that redirects to a subdirectory.
# Hostmonster.com
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]
I feel like I need to modify the .htaccess files in side my cakePHP app to ignore the subdirectory but I'm unsure how.
did you add
RewriteBase /subdirectory/
in your .htaccess in the directory where your /app and /cake folders are placed?

Resources