How to configure base url for subdomain on DigitalOcean VPS? - .htaccess

The code is working when in example.com, but when used in subdomain.example.com it only shows a blank page. The subdomain is hosted on a different VPS server rather when changed code with the absolute path, rather than {$_SERVER['HTTP_HOST']} to subdomain.example.com css, js works, but database connectivity is not establishing. Tried all methods nothing seems to work and it is worked in cpanel before, but not working in separate VPS in DigitalOcean.
$config['base_url'] = ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . "://{$_SERVER['HTTP_HOST']}/

Are you trying to get the base_url dynamically? check this than
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";

Related

How set base dir in htaccess

I have my website with structure of
mywebsite
index.php
index_admin.php
By rewriting though .htaccess
www.mywebsite.com/home/main --converts--> mywebsite/index.php
www.mywebsite.com/home/admin --converts--> mywebsite/index_admin.php
this is working (hosted)
Now I tried it to run on localhost for dev purpose using XAMPP Linux
url
localhost/mywebsite/index.php launched but when logined and navigate to url /home/admin it become localhost/home/admin which does not found. I want it to become /localhost/mywebsite/home/admin so that correctly navigate to index_admin.php file

Adding Fastly to a Heroku app does not forward to proper url

I currently have an Heroku app that is being served over a CDN. I have just added Fastly to my Heroku app as an addon and I am struggling to configure it properly. Here is my current configuration:
I have my domain registered on GoDaddy with the following CNAME configuration:
Host: www
Points to: my-site-herokuapp-com.global.ssl.fastly.net
TTL: Custom
Seconds: 600
Here is the GoDaddy forwarding configuration (not sure if this matters):
Forward to https://www.my-site.io/
(301 & forward only)
Here is my fastly configuration:
Domains:
my-site-herokuapp-com.global.ssl.fastly.net
*Provisioned for my-site via Heroku*
my-site.herokuapp.com
*Provisioned for my-site via Heroku*
www.my-site.io
And finally in Heroku in the domains configuration section of my app here are my settings:
Domain Name: my-site.io
DNS target: darwinian-kumquat-123456.herokudns.com
Domain Name: www.my-site.io
DNS target: serene-trout-123456.herokudns.com
Before I tried to make this change I had the CNAME pointing directly to: serene-trout-123456.herokudns.com an it was working fine. However after updating this value to the new Fastly value: my-site-herokuapp-com.global.ssl.fastly.net Fastly directs the site to my-site.herokuapp.com instead of just https://www.my-site.io. I followed the instructions listed here so not entirely sure where I have gone wrong. Any ideas?
Probably because you used redirect 301 and you are using the same browser as before before cleaning cache and data.
301 redirects are recomended only for very limited cases: once done the browsers will NOT refresh again any data from the original server.
There are plenty of posts regarding redirection 301, for example:
Cannot remove 301 redirect
htaccess 301 redirect - how to disable it?
https://www.exai.com/blog/301-redirects

Redirect /web url to / Symfony

My website is build with Symfony3.
I'm in front on a problem .
mywebsite.com/contact
is also accessible as
mywebsite.com/web/contact
I want to redirect all urls like mywebsite.com/web/something to mywebsite.com/something
Is it possible?
You have wrong configruation of your RootFolder, you need to setup your virtual hosts correctly

.htaccess issue for a subdomain site in Magento

I have created a Magento site for my main domain. Now I need to add one more store to my subdomain. I created a website, store, and store view. Then I added secure and insecure base URLs. After that I edited my .htaccess file which was in my root folder and it already contained the code for some stores which are hosted in the main domain, and here I need to create a subdomain. I used the below code in the .htaccess file:
SetEnvIf Host www\.abc\.domain\.in MAGE_RUN_CODE=website_code
SetEnvIf Host www\.abc\.domain\.in MAGE_RUN_TYPE=website
SetEnvIf Host ^abc\.domain\.in MAGE_RUN_CODE=website_code
SetEnvIf Host ^abc\.domain\.in MAGE_RUN_TYPE=website
Still the sub domain cannot connect to Magento... why is it so? Can anyone please help me?
I would check if the environment variable MAGE_RUN_CODE and MAGE_RUN_TYPE are correctly set and you can access them via PHP. You should see them in a file outputting phpinfo(). If they are not set it is possible that your server environment cannot handle environmental variables. The mod_env module should be activated on your server, else your solution will not work.
But you dont need to use the environment variables:
Which store will be launched from Magento is defined in the index.php in the root directory. At the end of the file you will find the following code:
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
change this to:
switch($_SERVER['HTTP_HOST']) {
case 'maindomain.com':
case 'www.maindomain.com':
$mageRunCode = 'firstsite';
$mageRunType = 'website';
break;
case 'subdomain.maindomain.com':
$mageRunCode = 'secondsite';
$mageRunType = 'website';
break;
}
Mage::run($mageRunCode, $mageRunType);
just change the $mageRunCode and desired $mageRunType with your actual values and it should work!

Different ways to do a redirect

I'm working on an old website and I've just found something strange. Www.mysite.com redirects to www.test.com, while mysite.com (non-www) redirects to www.other-site.com.
I've checked the htacces, and it only contains rules to redirect traffic to test.com. www.other-site.com is not present in the file. So how is it possible? Where should I check if there's a rule for this redirect?
Environment:
Centos server /
Apache /
Three sites are on different servers
This could be a DNS issue. If both www.test.com and test.com point to the same server then it is all server side. Virtual hosts can sometimes be the problem if you have Apache set that way then you will need a Virtual host for both www.test.com and test.com. I would say start with the DNS, then the apache config, then the site folder.
Hope that helps.

Resources