escape # using iis rewrite FileMapProvider - iis

using iis rewrite is great, but how does the module interpret a hashsign in the url.
This works:
/fromurl;/anotherurl
But this does not:
/fromurl#;/anotherurl
How do I "output excape" a hashsignin the from url.

I'm pretty sure the hashmark isn't sent to the server, so the rewrite module can't react to it.
This means that /fromurl and /fromurl# would result in the same url (as seen by the server)

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..!!

Netlify pretty query

I want to host a Netlify website where you can search for specific users. Currently its like this https://example.com/users?q=exampleuser . (its https://example.com/users.html but pretty url'ed)
But what I want is to make the URL query pretty. So the endresult should be https://example.com/users/exampleuser but it should still be a url query so the JavaScript can make calls based on the query.
e.g.:
https://example.com/users?q=test123 to
https://example.com/users/test123
https://example.com/users?q=example456 to
https://example.com/users/example456
The rewrite rule will work with:
/users q=:q /users/:q 200
When you navigate to https://example.com/users?q=exampleuser, you must have an existing endpoint at https://example.com/users/exampleuser/ or it will give a 404 status code, but will still rewrite the original path.
Note: If you have an existing endpoint at /users/ this method will not fallback if the rewrite path has an invalid endpoint. Meaning you can't fallback to /users/ endpoint if the query path is an invalid endpoint.

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
}

htaccess error with symbol =

I've a problem with an htaccess redirect.
In my Google Search Console I've found this link
http://www.example.com/index.php?id=10&L=2%27%2520AnD%25201%253D1--
that return error 403.
"index.php" doesn't exists in my website and I want write a rule that redirect this link to homepage.
The problem (in my opinion) it's that in this url there is a symbol "=" without an "*&var*" before.
The decoded version of the url is
http://www.example.com/index.php?id=10&L=2' AnD 1=1--
If I remove (manually) the symbol "=" (or it's encoded version "*%253D*") my htaccess woks perfectly.
Thanks
Lorenzo
**ADD NEW DETAILS**
OK, for url that has 1=1 it's probably sql-injection
But i've found also link as
http://www.example.com/index.php?eID=tx_cms_showpic&file=uploads%252Fpics%252FIMG_5213.jpg&width=800m&height=600m&bodyTag=%253Cbody%2520style%253D%2522margin%253A0%253B%2520background%253A%2523fff%253B%2522%253E&wrap=%253Ca%2520href%253D%2522javascript%253Aclose()%253B%2522%253E%2520%257C%2520%253C%252Fa%253E&md5=edc3c713d0e239f8a7e786cf52f29774
that decoded is
http://www.garnicristin.com/index.php?eID=tx_cms_showpic&file=uploads/pics/IMG_5213.jpg&width=800m&height=600m&bodyTag=&wrap= | &md5=edc3c713d0e239f8a7e786cf52f29774
I'm not shure that is older version of website (I not made older version) and the problem is the same, symbol = in url
AnD 1=1-
This looks like a lame attempt at a SQL injection attack. The fact that your server returned a 403 ("Forbidden") error might mean that a security module in your web server detected the attempt, and served the error.
In that case, I would not add a rule trying to cater to these requests.

setting redirect page for my Joomla website hosted in IIS

I am using Joomla with IIS in my website, and now i am trying to set a 404 redirect page in my Joomla website, i could use htaccess to make this when i am using apache, but for this IIS its gets tricky it seems.
you can see my web.config file here
any suggestion would be helpful..
There is no module available AFAIK - at least not for 1.6. But it is quite easy to do by yourself. You can use the solution in the joomla documentation. This is usable for any error code.
http://docs.joomla.org/Creating_a_Custom_404_Error_Page
if (($this->error->code) == '404') {
header('Location: /search');
exit;
}
The part behind the Location: is where you redirect to the page you want. e.g. /search in this case. The above is for 1.5, for 1.6 you need to use this:
if ($this->error->getCode() == '404') {
header('Location: /search');
exit;
} ;
in your IIS Console, right click on the website, goto the Custom Errors TAB,
scroll down to HTTP Error 404, Edit Properties, change the Message Type
to URL, and then type in the URL you want to change to.

Resources