url-rewriting

How to make .htaccess RewriteCond check domain name?

喜夏-厌秋 提交于 2019-12-03 09:46:19
I have this rule: RewriteRule ^(about|installation|mypages|privacy|terms)(/)*$ /index.php?kind=portal&id=1&page=$1&%{QUERY_STRING} [L] How can I change it so that it would work only for a specific domain, www.domain.com for example? You need a rewrite condition: RewriteCond %{HTTP_HOST} ^www.domain.com$ before your rewrite rule. If you list several rewrite conditions before your rules, everyone of them must match for the RewriteRule to be executed, for example: RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteCond %{HTTP_HOST} ^www.domain2.com$ which will of course NOT work, because the HTTP

Is it better to handle friendly/clean/pretty URLs with mod_rewrite or a language like PHP?

﹥>﹥吖頭↗ 提交于 2019-12-03 09:43:09
问题 I'm developing my first decent-sized PHP site, and I'm a bit confused about what the "right way" (assuming there ever is such a thing) to handle clean/friendly/pretty URLs in the application. The way I see it, there are two main options (I'll use a simplified social news site as an example): 1. Use mod_rewrite to handle all potential URLs. This would look similar, but not identical, to the following: RewriteRule ^article/?([^/]*)/?([^/]*)/?([^/]*) /content/articles.php?articleid=$1&slug=$2

How to include special characters in query strings

有些话、适合烂在心里 提交于 2019-12-03 09:41:06
The following URL works fine: http://localhost/mysite/mypage?param=123 However, if I want to put some special characters in `param like ?, /, \, then the URL becomes: http://localhost/mysite/mypage?param=a=?&b=/ or http://localhost/mysite/mypage?param=http://www.mysite.com/page2?a= \&b=... which won't work. How do I resolve this issue? You have to encode special characters in URLs. See: http://www.w3schools.com/tags/ref_urlencode.asp You need to encode the query parameters before combining them to form a url. The function needed here is encodeURIComponent .For example, the url you need to

IIS URL Rewrite: Add trailing slash except for .html and .aspx

ⅰ亾dé卋堺 提交于 2019-12-03 09:35:57
问题 Adding a trailing slash to all URLs through IIS URL Rewrite Module is widely spread, but how do I add exceptions for URLs that ends with .html and .aspx ? Today I have this: <rule name="Add trailing slash" stopProcessing="true"> <match url="(.*[^/])$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <!-- Doesn't seem to be working --> <!--<add input="{REQUEST_URI}" pattern="(.*?).html$"

What's the difference between Request.Url.Query and Request.QueryString?

萝らか妹 提交于 2019-12-03 09:08:37
问题 I have been tracking down a bug on a Url Rewriting application. The bug showed up as an encoding problem on some diacritic characters in the querystring. Basically, the problem was that a request which was basically /search.aspx?search=heřmánek was getting rewritten with a querystring of "search=he%c5%99m%c3%a1nek" The correct value (using some different, working code) was a rewrite of the querystring as "search=he%u0159m%u00e1nek" Note the difference between the two strings. However, if you

What Url rewriter do you use for ASP.Net? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-03 09:03:10
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I've looked at several URL rewriters for ASP.Net and IIS and was wondering what everyone else uses, and why. Here are the ones that I

IIS7 URL Rewrite returns 404 for WCF requests (reverse proxy)

╄→гoц情女王★ 提交于 2019-12-03 08:54:26
I am using IIS7.5, .net 4.0. I am working locally. I have installed Application Request Routing, Web Farm Framework, WebDeploy and UrlRewrite to set up a reverse proxy. This works fine for the most part. I have two websites: DefaultWebSite (port 80, app pool: Default App Pool (.net 4)) and Target (port 8085, app pool: TargetAppPool(my identity, .net 4)). I have a rewrite rule on DefaultWebSite (created as directed on IIS.net ) which redirects all localhost (port 80) traffic to localhost:8085 just as detailed in the above link. This works fine for most document types (.aspx, .xap, .htm, .ico)

Put images on CDN, using MVC3 on IIS7

ε祈祈猫儿з 提交于 2019-12-03 07:44:12
问题 I need to use CDN for all images on my site. So, Ive decided to use IIS Url-rewriting module, because edit manually all my site views - its impossible for me. So Ive made rules for IIS, eg: <rule name="cdn1" stopProcessing="true"> <match url="^Content/Images.*/(.*\.(png|jpeg|jpg|gif))$" /> <action type="Redirect" url="http://c200001.r9.cf1.rackcdn.com/{ToLower:{R:1}}" redirectType="Permanent" /> </rule> Its worked, but as you can see there is redirect type is used (301 Permanent). And I think

IIS7, RewritePath and IIS log files

喜欢而已 提交于 2019-12-03 07:35:50
问题 I am using Context.RewritePath() in ASP.NET 3.5 application running on IIS7. I am doing it in application BeginRequest event and everything works file. Requests for /sports are correctly rewritten to default.aspx?id=1, and so on. The problem is that in my IIS log I see GET requests for /Default.aspx?id=1 and not for /sports. This kind of code worked perfectly under IIS6. Using Microsoft Rewrite module is not an option, due to some business logic which has to be implemented. Thanks. EDIT: It

Do HTTP authentication over HTTPS with URL rewriting

倖福魔咒の 提交于 2019-12-03 07:15:29
I am trying to protect the ~/public_html/dev directory using http auth basic, but to make that secure I want to run it over ssl. The middle section of the below .htaccess file switches to https if the request URI begins with /dev and works. The last section of the file works as well but does not work properly with the https redirect. I basically want to be able to type http://www.example.com/dev/some_sub_dir/ and be redirected to https://www.example.com/dev/some_sub_dir/ and prompted for the http auth username and password. What currently happens is if I go to http://www.example.com/dev/some