I am trying to set up some rewrites in Netlify. Here's what I have in my _redirects file:
/search xyz=:abc https://example.com/search?xyz=:abc 200
/:abc https://example.com/search?xyz=:abc 200
The first line works as expected, the second line is not working. However, if I change HTTP status code for the second line to 301, it works. Why is that so? I really need to rewrite like the rule in second line. Is there any other modification I can do to make it work?
I got a response from Netlify email support.
Passing a path to a redirect as a query param is not meant to work,
especially as a 200 status.
So I made some minor changes to my server and this alternative redirect rule works fine:
/:abc https://example.com/search/:abc 200
Related
I am working with IIS (Internet Information Services ) in a windows server with URL Rewrite.
Need to redirect a URL (https://page.olddomain.com) to a new URL (https://page.newdomain.com). Everything remains the same, just need to URL to change if a user goes to https://page.olddomain.com.
Wondering if I'm following the right process of thought here.
I have a Inbound Rule created that should work.
Match URL
Requested URL: Matches the Pattern Using: Exact Match Pattern:
https ://page.olddomain.com (ignore case)
No conditions set
No server variables
Action
Action Type: Rewrite
Action Properties
Rewrite URL: https://page.newdomain.com
Append query string: checked
Am I missing anything here?
For this problem, if you can't implement the redirect step, I think it was caused by the wrong input in Pattern box which same with the comment mentioned by Lex Li.
We do not need to input the base url(such as https://page.olddomain.com) in Pattern, we just need to input the append url after the base url in Pattern. For your requirement, you just need to do it as below screenshot:
I suggest you to use "Regular Expressions" instead of "Exact Match", it can success implement your requirement.
And by the way, maybe you want to input / in Pattern(just ignore baseurl), but it will not work. So please input .* in Pattern. Apart from this, you'd better also define a condition to specify the HTTP_HOST equal your old host url.
For the comment you mentioned about SSL, I think it will not be affected by the redirect/rewrite rule.
Can someone explain to me why the first line of code delivers the desired result and the second piece of code returns 404? In the browser I searched localhost/ and localhost/css respectively.
1. http.Handle("/", http.FileServer(http.Dir("css"))) // works
2. http.Handle("/css", http.FileServer(http.Dir("css"))) // fails
returns the .css file at desired url (localhost/).
returns 404 at desired url (localhost/css).
I am not trying to serve both URLs at the same time. I comment out one or the other while I am trying to figure this out.
I solved the problem. The code below returned my css at the desired URL.
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css))))
What's odd is I could have sworn I tried this method. Must be something delaying the refresh of chrome.
I'm working through tutorials at http://ruby.bastardsbook.com/chapters/web-crawling/ and would like a little clarification on the Handling Redirects one, because the DOD website that the author uses as an example has been remade since the time of writing and I have run into some unexpected results while adjusting his code to work with the current version. (Please note that I don't need help rewriting the code, I'm just wondering why the stuff that happens here happens)
Specifically, I get code 301 no matter whether the page I'm trying to get with Net::HTTP.get_response exists or not. For example:
require 'net/http'
VALID = 'https://www.defense.gov/News/Contracts/Contract-View/Article/14038760'
INVALID = 'https://www.defense.gov/News/Contracts/Contract-View/Article/14038759'
resp = Net::HTTP.get_response(URI.parse(VALID))
puts resp.code # 301
resp = Net::HTTP.get_response(URI.parse(INVALID))
puts resp.code # 301
So, why does a valid address return a 301 Moved Permanently? And not only that, but actually trying to follow that redirect (useless in the scope of that tutorial, since the whole point was to skip anything that isn't a 2xx) as suggested here Ruby Net::HTTP - following 301 redirects gives me a 404, presumably because the redirect link has a trailing slash.
if resp.code == '301'
resp = Net::HTTP.get_response(URI.parse(resp.header['location']))
end
puts resp.code # 404
Even more puzzling to me is that when I looked at resp.body I found that despite that 404 error, I had, in fact, successfully downloaded the page's contents.
I would be very grateful if somebody walked me through whatever exactly is going on here. Thank you for your help and for taking your time in advance.
It doesn't seem like Ruby issue but just www.defense.gov manner. https://www.defense.gov/News/Contracts/Contract-View/Article/14038760 gives redirect (301) and then 404 despite the way to get it.
https://www.defense.gov/News/Contracts/Contract-View/Article/14038760 seems like a url to some missing data but https://www.defense.gov/News/Contracts/Contract-View/Article/1403876/ works fine (actual for 26.17.2017 03:24 +7). Why do you think the url with id 14038760 is valid?
I've found out that https://www.defense.gov/News/Contracts/Contract-View/Article/1403876 redirects to https://www.defense.gov/News/Contracts/Contract-View/Article/1403876/ (the same url but with trailing slash) while the url with trailing slash gives 200 response immediately.
What you can do? Try to get here https://www.defense.gov/News/Contracts/source/nav/ a list of actual contracts first and then request each of them with separated requests.
I am using JMeter for load testing.Because I want to simulate 200 users on a specific link: catalogus. I have the site now local. So the URL of the local site is: http://verploegenbalie.nl/product-catalog. But for testing I just use now 2 users. what also in the image is displaying. But the strange thing is, that if I dont check the:
-Follow Redirects option and
- Use Keep Alive option. then the link is not working. In the tree it becomes red and appears as: GET http://verploegenbalie.nl/product-catalog/product-catalog what is wrong, because it has to be:http://verploegenbalie.nl/product-catalog
But if I uncheck the two options. I get strange results.I get as output more then two responses. And If I look at the tab: Response Data I see: Object moved to here.
I make it clear with a couple of screenshots.
Thank you
If I do like this:
Then I will get by request this results:
GET http://product-catalog/
[no cookies]
Request Headers:
Connection: keep-alive
What ofcourse is not the correct URL.
Yes. If I do it like this:
Then the correct urls will be returned. But a other strange thing is that I have two users. You can see it on this image:
But the output gives by response data" 20 results. Where the number 20 comes from? See image:
what you've put in server name or ip field is wrong.
You've put the full URL while it should only contain the host part of the URL.
So "server name of ip field" mist contain:
verploegenbalie.nl
"Path" field must contain:
/product-catalog
I'm looking for an existing route (in Mindroute.Lemoon.Helpers.RouteHelper) that will already handle a path like http://www.mylemoonsite.com/blogpost3. It doesn't appear by requesting that URL that such a route is active, but it looks like some of the routes in RouteHelper.cs are attempting to cover that case. I can request http://www.mylemoonsite.com/blog/blogpost3, but I'm looking specifically for the former. Thanks.
Lemoon adds the catch-all route {slug*} to the end of the route-table, effectively catching everything that is not handled by other route handlers such as custom Controllers etc.
In order for Lemoon to respond to the request http://www.mylemoonsite.com/blogpost3 you need to have a page in your site with the permalink blogpost3. Since you get a response when requesting http://www.mylemoonsite.com/blog/blogpost3 I am guessing the permalink for your page is blog/blogpost3.
There are 2 things you can do to get a response from the path http://www.mylemoonsite.com/blogpost3.
Edit the permalink of the page
Add an alias to the page
If you add the alias blogpost3 the page will respond to both http://www.mylemoonsite.com/blogpost3 and http://www.mylemoonsite.com/blog/blogpost3. When adding the alias you can also specify the HTTP response code for the alias (200 OK, 301 Moved or 302 Found).