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

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:

Related

Full Media URL in Strapi

The Strapi API responds the media URLs as something like "url:'/uploads/thumbnail.png'".
I would like to get the complete URL that links to my file as value for "url". For example: "url:'https://example.org/uploads/thumbnail.png'"
The documentation also shows the full URL as response. How can I achieve this?
The full URLs come from using an upload provider such as AWS-S3 or Cloudinary. The local provider doesn't support full URLs at the moment.
There are some potentials reasons why you shouldn’t store a full URL, and respond with a full URL. I won’t dive into those reasons.
I suggest creating the entire request/response, or creating a middleware component to intercept the response.
Then you can modify the original url value with the site’s URL. Looping through the results with something like:
const serverHost = strapi.config.get('server.host', 'defaultValueIfUndefined');
url = serverHost + url;
See the following docs for more details:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html
https://docs.strapi.io/developer-docs/latest/development/backend-customization/middlewares.html#implementation

Laravel URL Helper return IP address instead of Domain name

I have a problem when trying to create the Url using URL helper. I'm using Laravel 6.
$verify_url = url("/verify");
This is return the URL with the IP address instead of the domain name.
I don't know if it is a problem with the Apache server or the code.
Please help me. Thanks.
Adding this directive to Apache Virtual Host config seems to have fixed it: ProxyPreserveHost On
But a better way to use your urls is to name them in your routes/web.php. For ex:
Route::post('/verify', 'HomeController#verify')->name('verify');
and wherever you need to access to this url just use like this:
$verify_url = route('verify');

Angular 2 App Behind Proxy

I may have looked over something obvious, but I am having trouble getting my angular2 app to work through a proxy. To my understanding I have to hardcode the base href for the app and the router to work, this seems problematic when the base url can change if I am going through a proxy. For example, if I host my app at http://example.com/ng2-app/ and then proxy to http://example.com/public/app/ I get an error in the browser console:
Cannot match any routes. Current segment: 'public'. Available routes: ['/sample', '/request-form', '/', '/request-view'].
Is there a way to make the app relative to their root URL and never hardcode the root? Am I misunderstanding how something works or overlooking something?

Allow URLs with Dashes on azure websites

I am trying to make an SEO friendly link for a downloads page
using codeigniter hosted on Azure Websites, now this is working:
www.example.com/downloads/viewfile/34
now when i generated this link :
www.example.com/downloads/viewfile/my-nice-file-name-34
the Url rewrite works great locally on a WAMP server, but when deployed to the remote (Azure Webites IIS ?) it gives the error:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I believe that the cause is: dash symbols are not allowed on IIS but is there a way arround ?
After all, i found out that its not the dash symbols that are causing the problem, but the words in the url itself
like yesterday i had www.example.com/downloads/viewfile/example-file-34
to some reason, having your domain-name in the url segments makes that error apear, so i simply replaced "mydomain" into nothing before generating the Url segment
$fileName = str_replace('mydomain','',$fileName);
return url_title($fileName.$fileId);
Now the same link above is www.example.com/downloads/viewfile/file-34 and its working fine.
i also noticed that same behavior is experienced when using some words like : ajax, json.
I hope this would be helful to somone.
In your routes.php file
Find
$route['translate_uri_dashes'] = FALSE;
Replace with
$route['translate_uri_dashes'] = TRUE;
You may need to look also into
URI Routing Codeigniter 3
http://www.codeigniter.com/user_guide/general/routing.html
Codeigniter 2 URI Routing
http://www.codeigniter.com/userguide2/general/routing.html

How can I rewrite URLs in the Zeus web server for Mobile useragent?

I need to redirect anyone with a mobile user agent to a file called mobile.php.
My web hosting provider, Net Registry uses the Zeus web server.
Here's the script I've written from my research
RULE_1_START:
# get the document root
map path into SCRATCH:DOCROOT from /
match IN:User-Agent into $ with iPad|iPod|iPhone|Android|s+Mobile
if matched then
set OUT:Location = /mobile.php
endif
RULE_1_END:
I used the instructions on my host's site.
I pasted that into their console and it has worked to do redirects. Net registry have some odd console thing that you submit and it takes 10 minutes to update the zeus server config (annoying as hell).
Anyway my issue is that it redirects me to the wrong location:
So if you visit the site, with a user agent string that contains ipad|ipod|android|\s+mobile then you will trigger it ()
It takes me here:
http://example.com.au/mobile.php,%20catalog/index.php
I can't work out how to fix that, or why that happens because at the moment this file exists:
http://example.com.au/mobile.php
as does this one:
http://example.com.au/index.php. Contents of this file are:
<?php header("Location: catalog/index.php");
Any ideas on how I can make this work more like an apache .htaccess url Rewrite?
the official Zeus documentation
Fixed it by changing
set OUT:Location = /mobile.php
to
set URL = /mobile.php
From the manual...
Using Request Rewrite Scripts
To use the request rewriting functionality, create a script in the Zeus Request
Rewrite Scripting Language. The script contains instructions telling the
Virtual Server how to change the URL or headers of requests that match specified criteria.
The Virtual Server compiles the script, and (if the rewrite functionality is
enabled) uses it every time it receives a request. It runs the commands in the
script, changing the URL if it matches the specified criteria. Once the script is
finished, the Virtual Server continues processing the resulting URL.Zeus Web Server 4.3 User Guide
142 Configuring URL Handling
When changing the URL, the rewrite functionality can only change the local
part of it, that is, the part of the URL after the host name. For example, if a
user requests http://www.myhost.com/sales/uk.html, the rewrite
functionality can only make changes to /sales/uk.html. This means that
you cannot use the rewrite functionality to change the request to refer to a
file on another Virtual Server.
For example, the following script illustrates how to change requests for any
HTML files in the /sales directory so that the user receives them from the
/newsales directory instead:
match URL into $ with ^/sales/(.).html
if matched set URL=/newsales/$1.html
The rewrite functionality can also change the HTTP headers that were received
with a request, and create new HTTP headers to be returned to the user. For
example, the following script changes the HTTP host header, so that a request
for www.mysite.com/subserver is redirected to the Subserver
www.subserver.mysite.com:
match URL into $ with ^/([^/]+)/(.)$
if matched then
set IN:Host = www.$1.mysite.com
set URL = /$2
endif

Resources