Multiple urls point to same application with query strings - iis

I have 2 domain name, let's say www.contoso.com and www.contoso.de , and in my IIS, i have 1 web app and it should take this request as
www.contoso.com -> www.internal.com?l=en
www.contoso.de -> www.internal.com?l=de
What's the best practice for this and rewrite all html anchors ( a href ) as appropriate ?

Related

Not able to access wildcard subdomain in Django app on online server

I am hosting a Django app on managed server with passenger_wsgi file. Let assume app main url is 'www.mysite.com'. When i visit this it shows me the homepage. What i want is to use wildcard subdomains in the app.
Like www.user1.mysite.com , www.user2.mysite.com , www.user3.mysite.com and so on, it can be any wildcard.
I have created a wildcard subdomain from cpanel like "*.mysite.com" , also added wildcard in my django settings.py file too. But when i visit the "www.user1.mysite.com" browser says
Not Found The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
settings.py
DEBUG = False
ALLOWED_HOSTS = ['.mysite.com','mysite.com']
Any kind of help would be great.
Thanks..!!

See Azure web app pages with zero views in Azure Application Insights

If it is even possible...
Goal: See a report of the number of views each page in my Azure web app has, and include the pages that have received zero views
Currently the page views report in Azure Application Insights that I have managed to create (based on the default report, shows all pages with >= 1 view. I would like to include in that report pages that have 0 views.
This is bare-bones version of the query I'm using in logs:
pageViews
| where timestamp between(datetime("2020-03-06T00:00:00.000Z")..datetime("2020-06-06T00:00:00.000Z"))
| summarize Ocurrences=count() by tostring(url)
The pages are in an Azure web app.
Does anyone know how to accomplish this, either using this method or another I'm not thinking of? Thank you for any help.
If the pages have zero view from client, it means that from client, there is no "page view" telemetry data being sent to application insights. Thus, application insights will not collect these zero-viewed page urls.
If you want to add these zero-viewd page to your report, you should hard-code these zero-viewed page urls in the query.
Here is an example, I use the datatable operator and union operator:
//use thie query to add the zero-viewd page url in this datatable
let query1=datatable (url:string,Ocurrences:long)
[
"https://localhost:44364/home/url1",0,
"https://localhost:44364/home/url2",0,
"https://localhost:44364/home/url3",0,
];
//use the query below for non-zero-viewd page
let query2=pageViews
| summarize Ocurrences=count() by tostring(url);
//union the 2 queries
union withsource=TableName query1,query2 | project url,Ocurrences
Here is the test result:

Redirect http to https via IIS

I have this application that I just installed a SSL certificate for. Yest I tried to redirect the users to use only the HTTPS://url.com. and prevent them from using the http://url.com site. However because I lack understanding the regular expressions to define the Pattern and the condition and unfortunately, I could not find a guide with some example of how to define those rules. I would like a concrete example of how to set this up https://{HTTP_HOST}{REQUEST_URI}.
Ensure you have the URL Rewrite feature added. In IIS manager configure the following in the URL rewrite section.
Create inbound rule (Blank Rule)
Requested URL : Matches the pattern
Using: Wildcards
Pattern: *
Conditions
Input: {HTTPS}
Type: Matches the pattern
Pattern: off
Action
Action Type: Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
Append Query String Checked
Redirect type: Found (302)
Once you have done this. Create a condition...
Right click your new rule
Conditions -> Add+
Condition Input : {QUERY_STRING}
Matches the Pattern
Pattern: off
Essentially it should look like this:
All traffic using a http request will be automatically redirected to the https port.
I think I've found a solution without url rewrite. In IIS, right click on the website, choose "Manage web site - Advanced settings", expand "Behaviour", expand "HSTS" and set to "True" the properties "Enabled" and "RedirectHttpToHttps".
Update:
As #jonasfh pointed out, you need anyway to have bindings both to http and https, because only the successful requests to http are redirected to https. So, if the request to http isn't successful (because http binding is not present) the redirect to https doesn't happen. Thank you.
Update2: just wanted to add that after the settings a site restart from IIS is needed.
My method from Global.asax
protected void Application_BeginRequest()
{
#if !DEBUG
if (!Context.Request.IsSecureConnection)
{
if (Context.Request.Url.ToString().Contains(".well-known")) return;
Response.StatusCode = 301;
Response.RedirectPermanent(Context.Request.Url.ToString().Replace("http:", "https:"));
}
#endif
}

Dynamic Subdomain Using Url Rewriting in yii

I want to create dynamic sub domain .I want to do with help of yii framework.
By giving url will generate virtual sub domain.
I have below url.
http://www.xyz.com/dq/logic/pd[controller]/dispall [method]/web [parameter 1]/web-designer [parameter 2]
From this url to I want to convert below url
http://web[ parameter 1].xyz.com/dq/logic/pd[method]/dispall[method]/web-designer [parameter 2].
Any one can help me about this ?

Routes in Codeigniter

I want to have a clean URL in CodeIgniter based application for User's Profile Information.
Please Take a look at URL formats below.
Actual URL : http://www.mydomain.com/index.php/users/profile/user1
I'm expecting users to have Personal URL's like
http://www.mydomain.com/user1
http://www.mydomain.com/user2
http://www.mydomain.com/user3
URL http://www.mydomain.com/user1 should process http://www.mydomain.com/index.php/users/profile/user1 in background execution.
I will be removing index.php from URL using Route library.
Thanks in advance for any sort of help.
Have a look at https://www.codeigniter.com/user_guide/general/routing.html.
$route['user(:num)'] = "users/profile/user/$1";
If you mean you want /anyusername to route to the users controller, you would have to put:
$route['(:any)'] = "users/profile/$1";
At the bottom of routes.php and every non user-URL above it. Otherwise every URL would be routed there, obviously. You will need to implement some mechanism in the users-controller to throw 404-errors, since you are routing all requests not catched in the routing rules above.
IN config/routes.php
add this line
$route['user(:num)'] = "users/profile/$1";

Resources