Questions tagged [rewrite]

URL Rewriting maps an incoming URL to a modified URL, so that the request is processes as if the original request was made to the modified URL. This is often used to provide more search engine friendly URLs.

2112 questions
23
votes
4 answers

nginx + PHP-FPM = "permission denied" error 13 in nginx log; configuration mistake?

I've got nginx 0.7x + PHP-FPM running under PHP 5.2.10 on one RHEL5 server, but trying to duplicate that setup under the bundled-in PHP-FPM in PHP 5.3.3 on a second server, I'm having some trouble with permission errors every time there's a GET. FPM…
Peter Kirn
  • 333
  • 1
  • 2
  • 5
20
votes
3 answers

nginx case insensitive rewrite

I am trying to make my nginx redirects as clean as possible. I understand ~* is for case insensitive but I can only get it to work in example 2. Example 1 rewrite ^/foobar http://www.youtube.com/watch?v=oHg5SJYRHA0 redirect; Example 2 -This…
milleruni
  • 303
  • 1
  • 2
  • 4
20
votes
1 answer

maintaining redirects in nginx from an external source

I am in the situation to give our marketing department the opportunity to maintain their redirects by their own. Until now, they passed the information to the IT department and we maintained it for them in nginx.conf. Some of these guys are quite…
Sascha
  • 538
  • 2
  • 5
  • 12
20
votes
2 answers

nginx rewrite for an url with parameters

I have an URL of this type: http://www.example.com/?param1=val1¶m2=¶m3=val3¶m4=val4¶m5=val5 And I want to redirect it to this one: http://www.example.com/newparam/val3/val4 So I have tried this rewrite rule with no success: rewrite…
David Morales
  • 685
  • 1
  • 5
  • 14
18
votes
4 answers

How to redirect requests to a different domain/url with nginx

I'm trying to redirect all users coming to a URL "http://example.com/something" to a URL like "http://answares.com/examples_com/something". I'm trying with code like this: server { listen 1.2.3.4:80; server_name "example.com"; rewrite ^(.*)…
user93656
  • 283
  • 1
  • 2
  • 5
17
votes
2 answers

Prevent URL Rewrite rules from being inherited by subdirectories in IIS7

I have a URL Rewrite setup for clean URLs in a CMS and my web.config looks like this:
Rich Jenks
  • 431
  • 1
  • 3
  • 8
17
votes
5 answers

How can I enforce that my urls always start with www?

I want to ensure that users come to www.mydomain.com even if they arrive through the alias mydomain.com. This is so that I have control over cookies on subdomains, and so that Google sees one single domain and not a hodge-podge of URLs. How can I do…
Magnar
  • 1,047
  • 2
  • 11
  • 15
17
votes
2 answers

"Hide" .html file extensions using nginx rewrites

I'm serving up a static site via nginx, and my goal is to replace URL's that look like: http://foo.com/bar.html with http://foo.com/bar The key being no trailing slash. I am currently doing something similar using location aliases but this is…
Doug Stephen
  • 305
  • 1
  • 3
  • 8
17
votes
2 answers

How to use IIS URL Rewrite with gzip compression

I've been trying to create outbound rules in IIS 7.5 on Windows 2008 R2 on a site that has static HTML pages and compression enabled. If I have any form of compression enabled (static or dynamic) I get this error: HTTP Error 500.52 - URL Rewrite…
mpipe3
  • 281
  • 1
  • 2
  • 4
16
votes
3 answers

Is it possible to replace content on every page passed through a proxy similar to how mod_rewrite is used for URLs?

Is it possible to replace content on every page passed through a proxy similar to how mod_rewrite is used for URLs? The documentation on substitute is not clear. I have some pages I am reverse proxying that have absolute paths. This breaks the site.…
ZZ9
  • 888
  • 3
  • 16
  • 47
15
votes
3 answers

Nginx rewrite URL only if file exists

I need to write a rewrite rule for Nginx so that if a user tries to go to an old image url: /images/path/to/image.png and the file doesnt exist, try to redirect to: /website_images/path/to/image.png ONLY if the image exists in the new URL, otherwise…
Jose Fernandez
  • 165
  • 1
  • 2
  • 6
14
votes
2 answers

Nginx multiple roots

I'd like to divert off requests to a particular sub-directory, to another root location. How? My existing block is: server { listen 80; server_name www.domain.com; location / { root /home/me/Documents/site1; …
13
votes
1 answer

My nginx rewrite is downloading the php file

I have the following rewrite rule I'm trying: location / { index index.php index.html; rewrite ^/test$ /test.php break; } And I also have: location ~ \.php$ { …
willdanceforfun
  • 557
  • 2
  • 11
  • 23
13
votes
2 answers

Nginx Rewrite Convert Querystring to Path

I whould like this simple rewrite rule: /somefolder/mypage.aspx?myid=4343&tab=overview to be redirected to: /folder/4343/overview/ I looked for some solutions and none actually worked.. I tried: rewrite…
YardenST
  • 255
  • 2
  • 3
  • 7
13
votes
3 answers

IIS URL Rewrite HTTP to HTTPS with Port

My website has two bindings: 1000 and 1443 (port 80/443 are in use by another website on the same IIS instance). Port 1000 is HTTP, port 1443 is HTTPS. What I want to do is redirect any incoming request using "htt p://server:1000" to…
Andy Arismendi
  • 1,188
  • 5
  • 16
  • 27