Simple url rewrite in nginx
How do I redirect: /text1 to / and /test2 to /something/else I tried putting: rewrite ^ /test1 / rewrite ^ /test2 /something/else Inside the server {} Asked by user80666 Just get rid of the space after the ^, and add the required ;: rewrite ^/test1$ /; rewrite ^/test2$ /something/else; The $ characters denote the end of the string. Get rid of them if you want /test1/blah to match as well as /test1. Edit: To send [...]
Continue Reading »How to rewrite these URLs?
I am brand new to URL rewriting. I am using an Apache rewriting module on IIS 7.5 (I think). Either way, I am able to do rewrites successfully, but am having trouble on a few key things. I want this pretty url to rewrite to the this ugly url: mydomain.com/bike/1234 (pretty) mydomain.com/index.cfm?Section=Bike&BikeID=1234 (ugly) This works great with this rule: RewriteRule ^bike/([0-9]+)$ /index.cfm?Section=Bike&BikeID$1 Issue #1 I want to be able to add a description and have [...]
Continue Reading »nginx: remove string in $host
server { server_name *.com.another.com; location / { root /var/www/html/$host; index index.html; } } On above example, if someone make a request to www.jaja.com.another.com, nginx will look in directory /var/www/html/www.jaja.com.another.com This is what I need: If someone make a request to www.jaja.com.another.com, I want nginx to look in directory /var/www/html/www.jaja.com In other words, the $host is www.jaja.com.another.com. I need to remove .another.com in the $host Nginx string replacement is new to me Asked by apasajja server [...]
Continue Reading »Nginx rewrite and – char in domain name
I have domain name which contains – char. For example my-domain.com. When I use rewrite, Nginx rewrites url wrongly, browser is redirected to my.com instead of my-domain.com. What is wrong in my rewrite rule? server { listen 80; server_name www.my-domain.com; rewrite ^/(.*) https://www.my-domain.com permanent; } Asked by newbie There doesn’t appear to be anything wrong with the server block you have used. I tested the exact block you provided, with a CentOS 6.2 Virtual Machine [...]
Continue Reading »mod_rewrite, clean URLs, and page content directories
I am using mod_rewrite in an .htaccess file in our root web directory so that we can use cleaner URLs for some specific cases. For example, we want to translate: http://example.com/Topic/ABCD/Type/Description into http://example.com/Topic.php?l=ABCD&e=Type&t=Description This seemed easy enough; the .htaccess file consists of: RewriteEngine on RewriteRule ^Topic/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /Topic.php?l=$1&e=$2&t=$3 [L] However, all the page’s content (.CSS files, images, etc.) ends up 404′ing because instead of, say, loading “/Common.css” from the directory relative to the rewritten URL: http://example.com/Common.css [...]
Continue Reading »IIS + UrlRewritingNet.UrlRewrite: Overwrite existing URL?
I’m trying to over-ride default behavior in my CMS, but without hacking the core or doing anything outright barbarous. As a result I’m trying to rewrite all requests to /umbraco/dialogs/preview.aspx?whatever so they’ll end up at /IveySuperPreview/IveySuperPreview.aspx?whatever It seems that UrlRewritingNet only grabs on to URL’s that don’t exist as real pages, though. I can rewrite, for example, /umbraco/dialogs/preview_test.aspx – but if I try it on the actual preview.aspx, nothing happens. Am I correct that this [...]
Continue Reading »Trying to use Nginx try_files to emulate Apache MultiViews
I want a request to http://example.com/foobar to return http://example.com/foobar.jpg. (Or .gif, .html, .whatever) This is trivial to do with Apache MultiViews, and it seems like it would be equally easy in Nginx. This question seems to imply that it’d be easy as try_files $uri $uri/ index.php; in the location block, but that doesn’t work. try_files $uri $uri/ =404; doesn’t work, nor does try_files $uri =404; or try_files $uri.* =404; Moving it between my location / [...]
Continue Reading »Can I configure IIS 7+ to do a dynamic reverse proxy based on the incoming hostname?
I am trying to configure IIS to proxy requests based on the incoming hostname. For example, if my proxy server is an IIS server located at www.proxy.com, a request to www.google.com.www.proxy.com would be proxied to www.google.com I have tried to set up a reverse proxy with a URL rewrite rule to rewrite *localhost* to {R:1}{R:2}, but I haven’t had any luck. From what I have read, it may only be possible if I specify exactly [...]
Continue Reading »Use IIS URL Rewrite module to point to a subdomain
My web page is located at maxpavlov.com/interesting/fileupload/ Can I use URL Rewrite module in IIS to have a user address bar show file.maxpavlov.com every time he visits the aforementioned url? Asked by Maxim V. Pavlov URL Rewrite can’t change the URL displayed in the address bar, per se. However, if you linked to file.maxpavlov.com (rather than maxpavlov.com/interesting/fileupload/), you could use URL Rewrite to rewrite that request to maxpavlov.com/interesting/fileupload/: <rule name=”CustomRule” enabled=”true” patternSyntax=”Wildcard” stopProcessing=”true”> <match url=”file.maxpavlov.com” [...]
Continue Reading »IIRF on IIS 6 Rejects Server Connections
My clients have two sites (call them, say, mainsite and subsite) that are run as subscription services. They want clients to be able to access subsite only if they’ve got a paid subscription on their main site, so anyone accessing subsite directly or not through mainsite should get redirected to mainsite (to buy a subscription). I’ve been tasked with handling this redirection, and since their servers are running on Windows Server 2003 with IIS 6, [...]
Continue Reading »Recent Posts
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?



