How to set root URL for Goutte driver? - symfony

I've started learning to use Behat and I've hit a snag: from what I understand the Goutte driver is simulating a user interaction that will follow pre-written scenarios, but when I launch Hehat through the console, i see that the url Goutte is reaching using visit('/') is http://localhost/ which is the WAMP homepage.
(I tried using visit() with the full url to no avail).
What I need is for Goutte to be by default at localhost:8000 which is where the test website is. So how can I specify which url is the root so that visit('/') will point to the homepage ?

I ended up finding out that just adding a base url variable to behat.yml was enough to do it, my bad. Although it was found in no documentation, just the luck of finding the right thread.

Related

Drupal 8 Redirects to external URLs are not allowed by default

I am setting up a website with Drupal, the website is deployed on the live server through bitbucket pipelines. Normally when I browse to myurl.com/user it redirects me to myurl.com/user/login however now I get this error:
Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.
I have already set-up the "trusted_host_paterns" however this doesn't seem to fix the problem.
trusted host patterns:
$settings['trusted_host_patterns'] = array(
'^myurl\.com$',
);
Just in case somebody else comes here: It is also possible, that you have migrated a multi language site to a different server / localhost, and in your database are still the old redirect domains, that will now no longer work.
To fix this, you need to manually change the following value in the database. Go to dr_config and search for language.negotiation
In the cryptic blob, search have a look for something like
{s:6:"source";s:6:"domain";
and change it to
{s:6:"source";s:6:"path_prefix";
afterwards empty all cache_* tables (to force a reprocessing of the configuration) and there is a good chance it might work then.
The pattern seems OK to me. However there is what I'd check:
Confirm using your browser that the redirect to /user/login happens to exactly myurl.com domain. Not www.myurl.com for example.
Try clearing cache as well.
Then looking through this post on DO
And then this one. It's a D8 issue not fixed yet.
I remember having a similar issue on one of my websites during development on a local environment and the issue was really in the pattern.
In the case you have this because of a multilingual site not finding the domains on localhost, put in settings.php:
$config['language.negotiation']['url']['domains']['en'] = 'my-en-url.localhost';
$config['language.negotiation']['url']['domains']['de'] = 'my-de-url.localhost';
$config['language.negotiation']['url']['domains']['es'] = 'my-es-url.localhost';
$config['language.negotiation']['url']['domains']['fr'] = 'my-fr-url.localhost';

Codekit 3 - External Server Issue

I've been using codekit for ages now, and now I've been using the version 3 since it came out.
I really like this app, but there's something I never really understood and I decided to post it here (hoping to finally understand how this works and how to make it works like I want).
I have MAMP pro installed, with some hosts.
Let's say I have this list of hosts with (fake) document root:
localhost -> documents/site1/dist
test -> documents/sitetest/dist
and let's assume that test is a wordpress site having the site url set to
http://test/ in the database.
In codekit, when I enable the browser refresh, the bottom options asks me to write down the address I would visit to see my website.
Now, if I navigate to http://test/ my WordPress website loads and I am able to see everything.
In codekit I then setup the browser refreshing options to be the following:
Animation: ticked
Refresh Delay: 0.0 seconds (default)
Preview: empty
Document-Root Subpath: empty
External Server Required: on
External Server Address: http://test/
Then when I click on the green dot (server) to preview my website, I'm expecting codekit to navigate to http://test:5757 and to properly display my website. This, unfortunately, is not the case. When I click on the preview (or server, it doesn't really make any difference for me) codekit navigates to my mac IP and the website is either not loading or loading without any external resource.
I don't think the issue is in the way I load the resource in WordPress (i use enqueue sources properly, and the website without using codekit refresh function works, load and displays as meant to).
So far, I always switched my current project to use the localhost host (changing the document root in MAMP pro) and then telling codekit to use the localhost ip as external server, but now it's a bit more complex, as I have way more projects and I was hoping not to change back and forth the document root to use codekit built in refreshing feature.
Is it possible? am I missing something here?
I read all I was able to find as well as watched the videos on codekit, but this bit here is still a bit unknown to me and any help would be really appreciated.
Thanks
PS: No need to mention I am on a MAC, right? :)
I don't believe I actually managed to fix this.
I'll leave the answer here in case somebody else is facing the same issue.
The problem I had was that my website http://test/ was using a theme called test.
Codekit, for refreshing the browser, uses a simple string search and replace in the URL, and so everything that looked like "test" in the url was replaced by the internal ip.
Quick example:
http://test/wp-content/themes/test/index.php
became
http://192.168.0.1:5757/wp-content/themes/192.168.0.1:5757/index.php
and of course no file where loaded successfully, as the path was wrong.
To fix this?
Just change the MAMP pro address to something that won't be present in the URL (in my case, the MAMP pro host called test became dev.test and problem solved.

How to PUT and POST image files to Apache2 using vhosts? (without PHP)

I want to simply POST and PUT image files to a server test.com, using apache2. This should result in storing the image file at the desired location. Lets say /srv/web/images/
What would be a working vhost configuration? Are there any modules that need to be activated? I am using apache2 on an ubuntu 12.04 server.
I think by default this is disabled in apache for obvious resons, nobdoy should be able to write to a server in the default configuration.
I want to simply secure it with http auth ("user1" / "pass1").
All the documentation and questions I find deal with PHP, but I thought should be possible using simply a REST URI and apache2 without PHP or cgi or a C program.
(Note: I am interessted in a solution without webdav (but I am not sure if the webdav module supports HTTP PUT which would be OK). And this question has got nothing to with forms or browsers, As an example the upload could use the program curl.)
Update: I found this message:
http://mail-archives.apache.org/mod_mbox/ant-ivy-user/201004.mbox/%3C4BBCA487.8000401#nitido.com%3E
It seems there once was a module mod_put, which is no longer in the repos of ubuntu. And that webdav has built in the functionality of PUT and DELETE.
If so, I am still unable to understand how to do the right VHOST configuration for simple FILE PUT operations.
I think nowadays for this kind of stuff you configure apache with WebDAV.

Tomcat 6 constantly redirecting URL to old one

I've done a lot of searching and not found anything like this, but I might not be using the right terms. My problem is this:
On a Tomcat 6 server, I originally deployed a Spring Webflow app with a context root of fred - to access it people went to myserver.com:8080/fred
The Spring code in that app changed all requests to have /spring after the context root - so the URL above would become myserver.com:8080/fred/spring - and this would bring up the index page.
That was all fine & dandy.
I rewrote the app to use Spring MVC instead, for reasons too boring to mention here, and as part of this removed the code that performed the /spring piece.
I am now trying to deploy it to the same Tomcat instance. It appears to deploy fine (after undeploying the old one).
However when I try to hit myserver.com:8080/fred to get the index page, it redirects to myserver.com:8080/fred/spring, and naturally this fails as that URL is not supported.
I've checked my config within the WAR, and also scanned through the following places in Tomcat:
conf directory
conf/catalina and subdirectories
webapps and subdirectories
work and subdirectories
I can't see anything referring to this /spring url rewrite. It does deploy and work successfully on my local version of Tomcat.
Could anyone offer any suggestions? All help is appreciated.
Sounds like your browser cached the redirect. If your site at myserver.com:8080 used hard redirects (301 Moved Permanently) to send users from /fred to /fred/spring your browser will remember that the next time you access the application. Try emptying the browser cache and trying again.
That would explain why everything is dandy on your local machine

Plone, behaviour of URLs

The situation is the following: I created a site with Plone, developed, used, but behind a test URL. Now it has to be published, but the test URL is not appropriate and I don't want to move the site. I think, if I use a redirect, it won't be appear in the URL-bar, only in the case of site start page. Am I wrong? (The test URL should not be used, because it will be a "semi-official" site.) What do you suggest to do?
As far as I can see Plone uses absolute URLs everywhere. I can add relative URLs, but if I create a new page, a new event, etc., then they have absolute URLs on other automatically generated inner pages. Is there any way to convert these URLs to relative paths? Is there any setting possibilty where only a checkbox changes this default setting?
Plone does not store your URLs in the database. It uses the inbound host header (and any virtual hosting configuration set up with rewrite rules in Apache or Nginx) to calculate the correct absolute URL when rendering the page.
In other words - as soon as you actually point the relevant domain name to the server with your Plone instance, it'll just work.
P.S.
You should put a bit more effort into asking your question. This is just a copy and paste of a half-finished email chain where you tried to get the answer from me in private. It's not very easy to understand what you're asking.
I think what you are looking for is url rewriting to handle virtual hosting. ie to get your site to appear as if it's the root url of a domain.
This is normally done via the webserver that normally sits in front of plone. For apache, here is a howto
http://plone.org/documentation/kb/plone-apache/virtualhost
for other servers
http://plone.org/documentation/manual/plone-community-developer-documentation/hosting
You can also achieve this directly in zope (via ZMI) using something called the Virtual Host
Monster. see http://docs.zope.org/zope2/zope2book/VirtualHosting.html
PS. I don't think your question is badly worded. Plone does serve pages with a "base" tag and what appears to be absolute urls. They aren't baked into the database but it's also not obvious that the solution to getting the url you want is the VHM url syntax and a proxying frontend webserver. There is a reason why it doesn't use relative urls... which I can't remember it was so long ago.

Resources