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.

learn more… | top users | synonyms (5)

15
votes
5answers
1k views

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 ...
14
votes
8answers
16k views

How to inject HTML code into every delivered HTML page?

I've got an Apache web server that delivers static HTML pages. For some reason I can't change the files themselves, but I still want to inject some HTML into every page that is being served. Is this ...
11
votes
4answers
15k views

how to restrict access to directory and subdirs

I need to restrict access to any files or subdirs in direstory "testdir". My conf: ... location ~* ^.+\.(jpg|txt)$ { root /var/www/site; } location /testdir { deny all; ...
11
votes
2answers
6k views

nginx url rewriting: difference between break and last

I don't understand the difference between break and last (flags of rewrite). The documentation is rather abstruse. I've tried to switch between the two in some of my configs, but I couldn't spot any ...
10
votes
4answers
15k views

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 ...
10
votes
3answers
10k views

How to rewrite the domain part of Set-Cookie in a nginx reverse proxy?

I have a simple nginx reverse proxy: server { server_name external.domain.com; location / { proxy_pass http://backend.int/; } } The problem is that Set-Cookie response headers contain ...
9
votes
2answers
4k views

mod_rewrite does not forward GET parameters

I'm having trouble setting up Apache with mod_rewrite on my development machine. Mod_rewrite is active, and works well for some rules. Some rules do not work as intended, like this one: RewriteRule ...
8
votes
9answers
810 views

Recommendation: Company website forced to https?

My company wants their "informational" website to be rewritten from HTTP to HTTPS. Technically this is not a big deal for me. But i have doubts if this is state-of-the-art since the only reason they ...
8
votes
4answers
3k views

Remove “www” and redirect to “https” with nginx

I want to create a rule in nginx that does two things: Removes the "www." from the request URI Redirects to "https" if the request URI is "http" There are plenty of examples of how to do each of ...
8
votes
2answers
4k views

“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 ...
8
votes
1answer
4k views

How can I export URL rewrite rules?

Is it possible to export URL rewrite rules for IIS7? I am setting up a duplicate of a website for internal use (testing) and want to duplicate all of the URL Rewrite rules without having to manually ...
7
votes
4answers
5k views

Configure IIS 7 Reverse Proxy to connect to TeamCity Tomcat

We have an IIS 7 webserver configured and would like to create a reverse proxy for a TeamCity installation using Tomcat on the same machine. The IIS server site is https://somesite and I would like ...
7
votes
1answer
3k views

IIS 7.5 Redirect / URL Rewrite to mobile version of website

I'm looking for an IIS solution (not programming) to redirect a website to a mobile version of the website. It looks like it might be possible, but not sure, with IIS Redirect or using IIS URL Rewrite ...
6
votes
4answers
4k views

nginx subdomain rewrite

Yet another nginx rewrite rule question How can I do a rewrite from http://www.*.domain.com to http://*.domain.com ? thanks in advance -- Deb EDIT: I'm sorry I didn't see the textile formatting ...
6
votes
2answers
2k views

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 ...
6
votes
3answers
3k views

Apache: Where to examine the redirection logs?

I have complicated RewriteCond and RewriteRule in one machine. And according to these rules some of the request will be redirected to another machine. So is there an Apache log that shows clearly how ...
6
votes
2answers
6k views

How to port Apache rewrite rules to cherokee?

I'm pretty new to cherokee, it's great and pretty straight forward except URL Rewrites. Is there a straight forward guide to it? Let me know. Also how would I port this: RewriteEngine on RewriteCond ...
6
votes
4answers
3k views

Why do I get a double trailing slash depending on where my RewriteRule is located?

I am using the following code to direct all www requests to non-www URLs: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.org$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] This ...
6
votes
2answers
1k views

Apache: Send pre-packed gzip'ed files

I want Apache to send static files gzip'ed over the wire, but also want Apache to not always gzip them over and over again. So I thought if it wouldn't be possible to deliver an .gz file if it exists. ...
6
votes
2answers
3k views

What should my Nginx rewrite rules be for Rails with Passenger for page caching in a subdirectory?

I'm using Nginx 0.7.64, Passenger 2.2.9, Rails 2.3.5. I have my page caching directory set to /public/cache, and I'd like to be able to serve cached pages when requested over HTTP, but always hit the ...
5
votes
2answers
11k views

Nginx Redirect via Proxy, Rewrite and Preserve URL

In Nginx we have been trying to redirect a URL as follows: http://example.com/some/path -> http://192.168.1.24 where the user still sees the original URL in their browser. Once the user is ...
5
votes
1answer
3k views

How to extract Only the file name from the request uri

I am trying to rewrite the request uri depending on the extension of the file, then extract only the file name from the uri and store it in another folder. The problem here is no predefined variable ...
5
votes
2answers
14k views

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: ...
5
votes
3answers
10k views

Nginx redirect one path to another

I'm sure this has been asked before, but I can't find a solution that works. A website has switched CMS services, but has the same domain, how do I set up an nginx rewrite for a single page? E.g. ...
5
votes
2answers
3k views

Temporarily redirect *all* HTTP/HTTPS requests in IIS to a “server maintenance” page

We've got an IIS server that hosts hundreds of separate web apps, and the physical database server that hosts these apps is going to be taken offline for maintenance for a brief period (we expect it ...
5
votes
1answer
3k views

HAProxy reqrep remove URI on backend request

real quick question regarding HAProxy reqrep. I am trying to rewrite/replace the request that gets sent to the backend. I have the following example domain and URIs, both sharing the same domain ...
5
votes
1answer
1k views

.htaccess rewrite http to https results in loop

On an apache 2.2 server running varnish, I am trying to redirect http -> to https for an entire Drupal Commons (http://commons.acquia.com/) site. Since varnish caches some redirects (R=301, but not ...
5
votes
2answers
2k views

IIS 7 rewriting subdomain to point at a specific port

Having installed Team Foundation Server 2010 on Windows Server 2008, I need an easy URL for our developers to access their repositories. The default URL for the TFS repositories is ...
5
votes
2answers
3k views

Disabling URL decoding in nginx proxy

When I browse to this URL: http://localhost:8080/foo/%5B-%5D server (nc -l 8080) receives it as-is: GET /foo/%5B-%5D HTTP/1.1 However when I proxy this application via nginx (1.1.19): location ...
5
votes
1answer
674 views

gallery2 and nginx with rewrite return file not found for file name with space (or + sign in url)

I have setup nginx with gallery2 on an internal server. Everything works fine under apache2 which I checked first, it used to be on apache2. Problem is: gallery2 seems to generate url with '+' sign ...
4
votes
4answers
2k views

Hiding non-standard ports in the address bar?

Some applications (such as Plone) default to serving http on ports other than 80 (eg 8080). Typically, to view those webapps you need to load http://mysite.tld:8080 instead of just http://mysite.tld ...
4
votes
2answers
4k views

Redirecting to the IP of an amazon EC2 instance

As you know amazon EC2 instances get an address like: ec2-72-44-40-153.z-2.compute-1.amazonaws.com If I have the domain example.com, is there any way that I can make bob.example.com or preferably ...
4
votes
1answer
6k views

Nginx: Rewrite rule for subfolder

I have a subdomain where I want to keep projects I am working on, in order to show these projects to clients. Here is the configuraion file from /etc/nginx/sites-available/projects: server { ...
4
votes
3answers
3k views

What URL should the browser display with this DNS configuration?

If I have the following records in the DNS: hostname Record Type address benmccormack.com A 216.10.244.61 www.benmccormack.com CNAME ...
4
votes
2answers
2k views

IIS7 URL Rewrite breaks for URLs containing + characters

I have an IIS7 server that acts as a reverse proxy for several other web servers. The other servers run on different ports, so the IIS7 server provides 'friendly URLs' and all on port 80. URL ...
4
votes
2answers
2k views

How Can I Configure nginx to Use Pretty URLs for Static Sites?

I've got several static sites (mostly generated by Sphinx), that I'm trying to host on my VPS. I've installed and configured nginx according to the guides, and I can successfully display my sites, but ...
4
votes
4answers
17k views

How do you configure IIS 7 to use a subdirectory as the default document?

So I have a website running on a discount asp.net account, and I put an asp.net mvc app in a subdirectory. If my url is 'www.website.com' and my app is in directory 'sample', then ...
4
votes
4answers
3k views

nginx rewrite base url

I would like the root url http://www.example.com to redirect to http://www.example.com/something/else This is because some weird WP plugin always sets a cookie on the base url, which doesn't let ...
4
votes
1answer
3k views

nginx: rewrite all except one location

Right now my nginx is rewriting several domains to one main domain which we are using. Here's one rule from my config: server { listen X.X.X.X:80; server_name .exampleblog.org; rewrite ^(.*) ...
4
votes
1answer
2k views

ProxyPass entire domain to Tomcat, including root

I have configured my VirtualHost example.com to proxy all requests to a Tomcat server ProxyPass / http://localhost:8088/app ProxyPassReverse / http://localhost:8088/app This works fine for URLs ...
4
votes
2answers
207 views

Can I make a simple calculation within a RewriteRule?

A change in how a site is structured means urls need changing from site/11-foo/21-bar to site/1-foo/1-bar i.e. I want to use a RewriteRule to subtract a constant (in this example, 10) from ...
4
votes
2answers
6k views

Apache Virtual Host Config www vs non-www, Rewrite or sServerAlias?

We have a central httpd.conf and we include confs for various virtual hosts. Until today, we didn't really have a need for "www.subdomain.site.com" domains, only "subdomain.site.com." Now we do, so I ...
4
votes
2answers
3k views

Precedence of RewriteRules in .htaccess file on Apache Server

I have a number of RewriteRules in my .htaccess file. However, one specific rule is only executed if I remove another specific rule, regardless of how I order the two rules. Here's the rule which ...
4
votes
1answer
528 views

IIS re-write from http to https only for subdomains of one domain only

I have an IIS7 web server with several sites running. Some of the sites are sub-domains of one domain and the others are totally separate domains. I want to use IIS re-write to redirect all the sub ...
4
votes
2answers
2k views

IIS Rewrite, rewrite maps and query strings

Please help me understand rewrite maps, I have this setup: <rewriteMap name="MyMap"> <add key="/pages" value="/website/pages/index.aspx" /> <add key="/pages/page-1" ...
4
votes
2answers
247 views

Why does a $1 backreference work in a rewrite with no subgroups?

Someone I'm working with committed a RewriteRule such as the following to SVN: RewriteRule ^admin/ebay.*$ /yii.php/$1 [L] I warned him that it may not work because there is no subgroup in the match ...
4
votes
1answer
981 views

Rewrite IIS served subdomain with content from other server/port

Our main web server is using IIS 6 and it obviously catches all port 80 traffic and we have another app served on a non-standard port (8443) that is hosted using Apache. For example: ...
4
votes
1answer
5k views

Rewrite a subdirectory to root on nginx

let's say I have a site http://domain/ and I put some files in a subdirectory /html_root/app/ and I use the following rewrite rule to rewrite this folder to my root: location / { root /html_root; ...
4
votes
2answers
774 views

URL rewrite in IIS 7

I have a question. I'm using IIS 7 URL rewrite. It works fine, but now I want this: http://www.example.com/http://www.domain.com to be: http://www.example.com/www.domain.com I have no clue on ...
4
votes
2answers
994 views

How do I set up URL Rewriting to a Heroku instance?

I'm more of an engineer than a devops guy, so please excuse me if this is extremely basic. My situation: I have a server on the example.edu network, so I don't control the main DNS interface to ...