Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Behaviour needs looking at. Requests returning 301. #316

Closed
austinpray opened this issue Aug 27, 2015 · 9 comments
Closed

404 Behaviour needs looking at. Requests returning 301. #316

austinpray opened this issue Aug 27, 2015 · 9 comments

Comments

@austinpray
Copy link
Contributor

Bare trells + bedrock master is giving me weird 404 behavior. It's returning 301 Moved Permanently for stuff that should return a 404.

For posterity:

trellis commit 8a84639
bedrock commit https://github.com/roots/bedrock/tree/5dc485e1058e3a32c218e8d90c9abb5929f16cd4

run the test

Reduced testcase: https://gist.github.com/austinpray/d067346e447910f9d70a

You can run the tests by cloning the gist:

git clone https://gist.github.com/d067346e447910f9d70a.git testTrellis
cd testTrellis
./test.sh

You can cleanup by running:

./cleanup.sh

results

VM is running
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 27 Aug 2015 21:21:05 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Pingback: http://example.dev/wp/xmlrpc.php
Location: http://example.dev/sdfsdfrsgv/
X-UA-Compatible: IE=Edge

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 27 Aug 2015 21:21:05 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Pingback: http://example.dev/wp/xmlrpc.php
Location: http://example.dev/completelybogus/
X-UA-Compatible: IE=Edge

done

full output

HEAD is now at 8a84639... Merge pull request #311 from roots/readme-usage
HEAD is now at 5dc485e... Merge pull request #197 from austinpray/bump
VM is running
* Hostname was NOT found in DNS cache
*   Trying 192.168.50.5...
* Connected to example.dev (192.168.50.5) port 80 (#0)
> HEAD /sdfsdfrsgv HTTP/1.1
> User-Agent: curl/7.37.1
> Host: example.dev
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
* Server nginx is not blacklisted
< Server: nginx
Server: nginx
< Date: Thu, 27 Aug 2015 21:20:11 GMT
Date: Thu, 27 Aug 2015 21:20:11 GMT
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Connection: keep-alive
Connection: keep-alive
< X-Pingback: http://example.dev/wp/xmlrpc.php
X-Pingback: http://example.dev/wp/xmlrpc.php
< Location: http://example.dev/sdfsdfrsgv/
Location: http://example.dev/sdfsdfrsgv/
< X-UA-Compatible: IE=Edge
X-UA-Compatible: IE=Edge

<
* Connection #0 to host example.dev left intact
* Hostname was NOT found in DNS cache
*   Trying 192.168.50.5...
* Connected to example.dev (192.168.50.5) port 80 (#0)
> HEAD /completelybogus HTTP/1.1
> User-Agent: curl/7.37.1
> Host: example.dev
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
* Server nginx is not blacklisted
< Server: nginx
Server: nginx
< Date: Thu, 27 Aug 2015 21:20:11 GMT
Date: Thu, 27 Aug 2015 21:20:11 GMT
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Connection: keep-alive
Connection: keep-alive
< X-Pingback: http://example.dev/wp/xmlrpc.php
X-Pingback: http://example.dev/wp/xmlrpc.php
< Location: http://example.dev/completelybogus/
Location: http://example.dev/completelybogus/
< X-UA-Compatible: IE=Edge
X-UA-Compatible: IE=Edge

<
* Connection #0 to host example.dev left intact
done

edit: added a success case curl http://example.dev/ to show that the setup is working in the first place.

@kalenjohnson
Copy link
Contributor

ty for success case 💯

@louim
Copy link
Contributor

louim commented Aug 27, 2015

Seen this before. I believe it is due to how Nginx rewrite are made. Changing the Wordpress permalink setting to "post" make it work correctly.

@austinpray
Copy link
Contributor Author

@louim yep. That fixes it.

https://codex.wordpress.org/Nginx#URL_Rewrites_.2F_Permalinks

So the question is: do we care?

@kalenjohnson
Copy link
Contributor

Perhaps we could add a WP-CLI command to set the site to pretty permalinks by default. I mean, who doesn't turn those on anyways?

@retlehs
Copy link
Member

retlehs commented Aug 27, 2015

@kalenjohnson++

@retlehs
Copy link
Member

retlehs commented Sep 1, 2015

seems like permalinks should be enabled by default as of 4.2: https://core.trac.wordpress.org/ticket/6481

@kalenjohnson
Copy link
Contributor

I'm betting it's because WP is installed with wp-cli. I would assume that installing WP via the 5-minute installer would have pretty permalinks enabled.

Man, it's been a while since I did it that way 😂

@louim
Copy link
Contributor

louim commented Sep 1, 2015

@kalenjohnson I don't believe it makes a difference, or maybe the wp-cli has some hack to install without using the install method of WordPress? This is the function used to check if permalinks can be enabled: https://developer.wordpress.org/reference/functions/wp_install_maybe_enable_pretty_permalinks/

@kalenjohnson
Copy link
Contributor

@louim yep I've been looking at it. I'm not sure if the permalink testing works from the command line though... could be completely off base, that was just my assumption.

I'm also going off memory, but I'm pretty sure in the last few months, definitely post-4.2 release, I've had to enable pretty permalinks on a Trellis site. Should probably just give it a try again though to confirm.

swalkinshaw added a commit that referenced this issue Dec 28, 2015
Fix #316 - Add wp-cli permalink command
primozcigler pushed a commit to proteusthemes/pt-ops that referenced this issue Mar 10, 2016
This resolves roots#316 by adding wp-cli permalink commands to check and then set the rewrite rules when none are set

Conflicts:
	group_vars/development/wordpress_sites.yml
	group_vars/production/wordpress_sites.yml
	group_vars/staging/wordpress_sites.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants