Score:0

How do I redirect users from the server IP to the URL with path?

ru flag

I'm working on a Drupal site. Everything works when I access the site using its IP address. My supervisor made an Nginx redirection on another server to the site's IP. Now the site should be accessible from http://example.com/services/drupal, but it isn't.

I have tried modifying the settings.php file with the following lines.

$base_url = 'example.com/services/drupal';
$settings['trusted_host_patterns'] = [
    '^example.com$',
    '^example\.com\/services\/drupal$',
    '^example\.com\/services\/drupal',
];
$base_path = 'services/drupal';

How could I get my site to work correctly on http://example.com/services/drupal?

apaderno avatar
us flag
Welcome to Drupal Answers! The `$settings['trusted_host_patterns']` array is only for the domain, not for domain and path. That doesn't explain why the site isn't accessible from http://example.com/services/drupal, though.
apaderno avatar
us flag
Does the IP points to example.com or to a different domain name?
Mattias avatar
ru flag
Thanks for a welcome! IP does not point to any domain name.
apaderno avatar
us flag
The question speaks of IP, but the code sets the base URL to example.com/services/drupal, which I take it means example.com is a domain name associated to that IP that works when used in a browser. (_Everything works if in the browser I use the IP address to connect to the site. My supervisor made an Nginx redirection on another server to the site's IP._) Also, what's that Nginix redirection?
apaderno avatar
us flag
A domain name doesn't work, if it's not associated to an IP. That's true for any domain name, including stackexchange.com or drupal.org.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.