Cloudfront Cache Behaviour wildcard - amazon-cloudfront

In cloudfront if I only want to match path pattern like /test1 /test2 but not /test, can I use /test* ?
Also is it possible to do the same for origin, like test*.example.com to match test1.example.com but not test.example.com?
Thanks

Related

DNS Wildcard entry and specific nested subdomain

Let's say we have the following two entries in our zonefile for mydomain.de
* IN A 35.234.100.200
mytest.test IN A 35.234.100.201
We would now expect that example.mydomain.de resolves to 35.234.100.200.
Instead it does not resolve to anything. Why is that?
Note that when we remove the second entry, the wildcard entry does apply and example.mydomain.de resolves to 35.234.100.200.
Update:
Our bad. The above shown configuration works as expected. We seem to have seen some other unrelated issue.

How to make apache treat query string as file name?

I mirrored a site to local server with wget and the file names locally look like this:
comments
comments?id=123
Locally these are static files that show unique content.
But when I access second file in browser it keeps showing content from file comments and appends the query string to it ?id=123 so it is not showing content from file comments?id=123
It loads the correct file if I manually encode the ? TO %3F in browser window and I type:
comments%3Fid=123
Is there a way to fix this ? Maybe make apache stop treating ? as query separator and treat it as file name character ? Or make an URL rewrite and change ? into %3F ?
Edit: Indeed too many problems caused by ? in file name and requests. I ended up using the wget option --restrict-file-names=windows that would convert ? into an # when saving file name.
The short answer is "don't do that."
The longer answer is that ? is a reserved character in URLs, using it as a part of a filename is going to cause problems forever, and the recommended solution is to pick a different character to use in those filenames. There are many to choose from - just avoid ? & # and # and you'll probably be fine.
If you insist on keeping the file name (or if you don't have an option) try:
RewriteCond %{QUERY_STRING} (.*)
RewriteRule (.*) $1%%3F%1 [NE]
However, this is going to fire any time you have a query string, which is likely not what you want.

SearchBlox custom paths setup

I've got a path like: https://somesite/build/namez/javadoc/index.htm
Where namez - can change.
There are also paths like: https://somesite/build/namez/javadoc/somedoc/index.htm
I need to limit indexing only on https://somesite/build/*/javadoc/index.htm
How do I do this?
You can use an Allow Paths value within the SearchBlox Collection settings as follows:
/javadoc/
This will limit the crawler to only urls that contain /javadoc/.

URLs with symbol "%" at the end make http error, how to prevent it with htaccess?

I have a doubt with some of my URLs from my acces_log . There are some URLs from external sites linking me like http://domain.com/url_name.htm% (yes, with %).
Then... my server returns http error, I need to redirect this fake URLs to the correct way, and I thought in htaccess.
I only need to detect the % symbol in the last character of URL, and redirect without it.
http://domain.com/url_name.htm% --> http://domain.com/url_name.htm
How can I do this? I was trying with some samples with ? symbol but I didn't have lucky.
Thanks!
I already found the mistake...
It seems that some malformed URLs don't pass to vhost, then these petitions don't read the .htaccess.
The only way to solve this, is adding in httpd.conf the ErrorDocument 400 directive... Not is the best option for servers with different vhosts.. because all of the will have the same behaviour... but I think that is the only way for this case.
Quotation from Apache documentation:
Although most error messages can be overriden, there are certain circumstances where the >internal messages are used regardless of the setting of ErrorDocument. In particular, if a >malformed request is detected, normal request processing will be immediately halted and the >internal error message returned. This is necessary to guard against security problems >caused by bad requests.
Thanks anyway!!
This page is super helpful about the .htaccess rules.
http://www.helicontech.com/isapi_rewrite/doc/RewriteRule.htm
I saw a few solutions to this that use a small php script too. IE this one replaces #
.htaccess
RewriteRule old.php redirect.php? url=http://example.com/new.php|hash [R=301,QSA,L]
redirect.php
<?php
$new_url = str_replace("|", "#", $_GET['url']);
header("Location: ".$new_url, 301);
die;
?>

Nginx with Clean Urls, Get Parameters, and PHP-FPM

I was curious to know if it was possible to somehow configure nginx so that it will parse url arguments without specifying .php at the end of the filename before the arguments are sent.
For example, let's say I have an account module which processes which aspect of the account to load, based on the argument sent. If the argument is ?sk='login', it will load the login module. If it is ?sk='register', it will load the registration module - and so on and so forth.
The problem is that when I type http://host/account?sk='login', I do not get anything via $_GET when I try to print the values within the array. The thing is that the clean URL does load the file which is supposed to manage the $_GET arguments, except it will not actually process $_GET unless I specify .php at the end of the filename.
I'm guessing there's an nginx or php-fpm configuration somehow which allows this.
Is this possible?
I figured it out:
The idea, with nginx, is to define a location, specify that location's root, and then do a try_files while specifying the $uri variable and the .php file to execute, with the arguments.
For example:
location /somelocation {
root /path/to/somelocation/on/server;
try_files $uri /somelocation/somefile.php?key=$args;
}
Rather than typing http://host/somelocation?key='someargument', you would specify /somelocation?someargument
From there on, when you call $_GET[ 'key' ] in your php, it will output someargument with a key of key. The key can be whatever you specify.

Resources