rewrite url to url:port number - url-rewriting

how can I rewrite the next url request:
http://mydomain.com/virtualDirectory/default.aspx?param1=2&param2=car
to:
http://mydomain.com:8888/virtualDirectory/default.aspx?param1=2&param2=car
Best regards.

You should install the URL Rewrite and the ARR (Application Request Routing) modules for IIS. Here are two links on how these can work together to create a reverse proxy to do what you want:
Reverse Proxy with URL Rewrite v2 and Application Request
Routing
Setting up a Reverse Proxy using IIS, URL Rewrite and
ARR

Related

Application gateway rewrite rule, remove / at the end of url

i have an application gateway v2 standard with private ip and i have this use case:
on imperva we have this url myapp.mydomain.com with a redirect to www.mydomain.com/something/, this url is on an application gateway but i see that app gw put at the end the / . I would like to remove it to have www.mydomain.com/something, there is a way to remove it?
Thanks
I tried to reproduce the same in my environment I got the same URL like below:
Application gateway is used to make URL redirects, however one of the routing rules, which takes users to an external website, adds a trailing slash "/" at the end of the URL and causes problems to resolve this issue try the below step:
In your backend target try to disable the include path as NO like below:
When I try to pass the URL I got the result successfully like below:

Laravel generates wrong route behind reverse proxy with path prefix

Running Laravel behind Traefik as reverse proxy, with a Path Prefix (eg /api/ => Laravel).
Laravel is served by Nginx and Php-fpm.
Laravel use Symfony HTTP foundation to generate route URL.
Symfony is not seeing correctly the base path, and generate URL without /api/ prefix.
As a dirty workaround, I fixed it by doing as the 1st line on index.php:
$_SERVER['SCRIPT_NAME'] = '/api/' . $_SERVER['SCRIPT_NAME'];
How can I force the full URL or the base path?
This was fixed by Symfony team, for Symfony 5.2:
my original issue: https://github.com/symfony/symfony/issues/36809
the PR: https://github.com/symfony/symfony/pull/37734

Yii2 https URLs do not work

I try to run my local copy of my yii2 site with https.
I use this in config to force http url to https
'on beforeRequest' => function ($event) {
if(!Yii::$app->request->isSecureConnection){
$url = Yii::$app->request->getAbsoluteUrl();
$url = str_replace('http:', 'https:', $url);
Yii::$app->getResponse()->redirect($url);
Yii::$app->end();
}
},
The only url I can reach is the home page i.e. a bare url such as
example.ext
Other URLs give
Not Found The requested URL /site/index was not found on this server.
When removing the 'onbeforerequest' in the config, I can reach every http URL.
Question: why https URLs become unreachable?
Eventually I made out that there was no url rewrite for pretty url in the virtualhost litening to 443 port.
Adding the recommended rewrite rule in it solved the problem.
#stfsngue: Thank you for comment
Do you see any particular reason for preferring .htacces to 'onbeforeRequest' to force https?

Nginx https redirects - stop further rules processing

I'm trying to configure http and https redirects from an old site to a new one.
According to the rewrite directive docs:
If the replacement string begins with http:// then the client will
be redirected, and any further rewrite directives are terminated.
And I'm trying to achieve the same with https to no avail.
This is my server config:
listen 80;
listen 443 ssl;
server_name mydomain.com
rewrite ^/path/resource(.*)$ $scheme://newdomain.com/newpath/resource$1 permanent;
...
return 301 http://newdomain.com/newpath/;
Using http I get what I'm looking for: if I access mydomain.com/path/resource I'm redirected to newdomain.com/newpath/resource.
However, the same with https redirects me to http://newdomain.com/newpath/.
I have rewrite_log on and in both cases the rewrite rule is matched but the https protocol does not stop further rules processing.
I have the feeling that either I'm missing something really obvious or I'm not approaching this problem properly. I wouldn't mind doing this in any different way at all if it works.
Have any of you out there any idea on how to achieve the http redirect with https too?
I usually like to use return instead of rewrite for redirects, try matching the path with a location block
location ~ /path/resource(.*) {
return 301 $scheme://newdomain.com/newpath/resource$1;
}
I think this way you know for sure there will be no further processing, because it's only 1 line, try it and tell me how it goes.
PS: This will maintain the $scheme of the request, requests to http:// will be redirected to a http:// and https:// will be redirected to https://

Accessing HTTP headers in ISAPI Rewrite 3

Is there any way to access HTTP headers in ISAPI_Rewrite module? Didn't find anything about it. I know IIS URL Rewrite allows you to access headers as server variables - {HTTP_HEADER_NAME} - is there something similar here?
Uh, nevermind...
Missed a line in a documentation:
HTTP header value with the syntax %{HTTP:header}.
http://www.helicontech.com/isapi_rewrite/doc/RewriteCond.htm

Resources