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)

2
votes
1answer
709 views

Nginx rewite rules 403 error

I am having trouble with converting .htaccess files to nginx. I have 3 .htaccess files. The first .htaccess file is located in the document root and is as follows: Options +FollowSymLinks ...
-3
votes
2answers
354 views

How do I redirect .php pages to .html pages? [duplicate]

Possible Duplicate: Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask? I have a dynamic website, so all the pages are in .php, but I want to show an address ...
11
votes
4answers
19k 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 ...
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 ...
11
votes
3answers
15k 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 ...
10
votes
3answers
17k views

nginx rewrite for an url with parameters

I have an URL of this type: http://www.example.com/?param1=val1&param2=&param3=val3&param4=val4&param5=val5 And I want to redirect it to this one: ...
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 ...
3
votes
2answers
2k views

Apache-style multiviews with Nginx

I'm interested in switching from Apache/mod_php to Nginx for some non-CMS sites I'm running. The sites in question are either completely static HTML files or simple PHP, but the one thing they have in ...
15
votes
2answers
31k 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 ...
2
votes
1answer
3k views

How to use Apache to proxy from subfolder to other server

Given the following url: domain.com/wiki/ I'd like apache to redirect all requests below that (so domain.com/wiki/*) to otherdomain.com:8080/. But the trick is I want the user to always see ...
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 ...
3
votes
2answers
258 views

Is there an Elegant solution to rewrite long image?query-urls into cachable_nice_urls, using only apache htaccess?

this is a pain in the ass-problem! Whicever genius solves this riddle will receive paypal donation to eat diner for two. Now lets get started. Given: most proxies, do not cache resources with a "?" in ...
3
votes
4answers
7k views

How to redirect non-www to www without hardcoding using .htaccess?

RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ...causes a perfect, non-hardcoding 301 redirect from "www to non-www", ...
5
votes
4answers
23k 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 ...
1
vote
1answer
475 views

Using Virtual Domains with WordPress and Cherokee Web Server

I'm trying to configure WordPress to work with Cherokee Web Server. The multi-site set up in WordPress is yyy.com and uses 'sub-domains'. Thus, I have sites like aaa.yyy.com, bbb.yyy.com - they all ...
1
vote
1answer
2k views

IIS7 URL Rewrite and Symbols

I'm migrating from IIS6 with ISAPI_Rewrite to IIS7 using their Rewrite module. I have a "pretty" url that looks like this: /Shop/Q%26A. Of course that it Q&A encoded. IIS7 doesn't seem to like it. ...
16
votes
8answers
20k 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 ...
13
votes
2answers
8k 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 ...
9
votes
5answers
4k 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

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

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 ...
7
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 ...
5
votes
1answer
4k 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 ...
4
votes
1answer
3k views

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

nginx- Rewrite URL with Trailing Slash

I have a specialized set of rewrite rules to accommodate a mutli site cms setup. I am trying to have nginx force a trailing slash on the request URL. I would like it to redirect requests for ...
2
votes
1answer
73 views

HAProxy/Varnish: redirecting a percentage of traffic

I'm trying to measure separate statistics for two different versions of a web page. So I need to redirect a certain percentage of my web traffic to a different page than the one requested (i.e. 20% of ...
2
votes
3answers
6k views

How do I make RewriteCond %{HTTP_COOKIE} match a cookie value exactly? [duplicate]

How do I make my rule match an exact value of a cookie? I've tried: RewriteCond %{HTTP_COOKIE} ^its=me$ [NC] RewriteCond %{HTTP_COOKIE} its=^me$ [NC] RewriteCond %{HTTP_COOKIE} its="me" [NC] ...
2
votes
1answer
5k views

Hide path to backend with Nginx

I have OpenNMS running on host B-beta with the following URL: http://b-beta:8980/opennms I would like to use NginX to hide this path accessible from host a-alpha like this: ...
2
votes
1answer
3k views

Rewriting a query-string part as a path part using nginx?

How do I rewrite URIs of the form /one/two?path=three&foo=bar to /one/two/three?foo=bar using nginx?
2
votes
1answer
10k views

URL rewrite with multiple parameters using .htaccess

I've been trying to create some rewrite rules for the last few hours and I'm failing miserably. If anyone could help, I would be extremely grateful. I have four different types of rewrites I'm trying ...
1
vote
1answer
798 views

Apache Rewrite or Redirect?

I want to redirect a http://site.com/ to http://site.com/url. What is the simplest way to do this? I tried editing httpd.conf and to the redirect command. It didn't worked. Also I tried creating a ...
0
votes
1answer
259 views

Compact Redirects in Apache/htaccess. How? [An Elegant Coding Question]

when setting my redirects in htaccess, i have trouble setting/combining various domains when they all go to the same homepage. I can do them separate, but that isn't neat/elegant. How to rewrite the ...
0
votes
1answer
200 views

url rewrite to make generated thumnails cache like static, a syntax question

this is a pain in the ass-problem!! Given: most proxies, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for ...
6
votes
1answer
10k views

How to quick and easy remove part of an URL in Nginx with HttpRewriteModule?

I know about the HttpRewriteModule, but I don't really know how to handle regex and I would need to redirect all URLs within a certain directory to another, specifically ...
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 ...
3
votes
1answer
62 views

Multiple rule Apache rewrite

I am trying to set up a hierarchy five levels deep with mod_rewrite. This is what I have put together at this point. It works for the last two levels (the first and second rule) but not after that. ...
3
votes
1answer
903 views

Apache mod-rewrite rule to change subdomain.domain.tld to domain.tld/subdomain

What would the rewrite rule be to change subdomain.domain.tld to domain.tld/subdomain? Or should I look at a VirtualServer directive to take subdomain.domain.tld and serve it from a DocRoot that ...
3
votes
3answers
4k views

Nginx rewrite urls without redirection

I used rewrite directives below in nginx to rewrite urls of static files to external CDN server. rewrite ^/static/(css|images|js)/([a-z_\-\.]+)$ http://cdn.domain.com/$1_$2 last; It works but it ...
3
votes
2answers
2k views

Using IIS7 as a reverse proxy

I'm setting up a server at home to host a few small websites. One of them is .NET based and needs IIS, the others are PHP based and need Apache. So, I have both IIS 7 and Apache 2.2.x installed on ...
2
votes
1answer
74 views

What is the difference between Nginx variables $host, $http_host, and $server_name?

What is the difference between the three Nginx variables $host, $http_host, and $server_name? I have a rewrite rule where I'm not sure which one I should be using: location = /vb/showthread.php { ...
2
votes
1answer
329 views

Nginx redirect a particular page from https to http

How can I redirect a specific https page to http, example: https://example.com/foo -> http://example.com/foo Only for the page foo, and no other page. Thank you.
2
votes
1answer
12k views

IIS URL Rewrite Module Query String Parameters

Is it possible to use URL Rewrite to provide more complex query string functionality than the "Append query string" checkbox that it has? Specifically, is it possible to specify the keys for certain ...
2
votes
2answers
752 views

Order of mod_rewrite rules in .htaccess not being followed

We're trying to enforce HTTPS on certain URLs and HTTP on others. We are also rewriting URLs so all requests go through our index.php. Here is our .htaccess file. # enable mod_rewrite RewriteEngine ...
1
vote
1answer
153 views

Nginx and Wordpress permalinks are broken if blog is not in root

So I have installed nginx and Wordpress on my server. However, my blog is not in domain root. (e.g. example.com/blog and contents are in /var/www/example.com/blog) I am using settings below in nginx ...
1
vote
1answer
170 views

Setting expires header to multiple location block in nginx

In my nginx config, I have serveral location blocks, e.g. location ~* /a { ..} location ~* /b { ..} location ~* /c { ..} And I want to apply the expires header to all of above blocks, e.g. ...
1
vote
0answers
281 views

How to deal with certain characters in IIS URL Rewrite

I had a question on how to rewrite a url and had a great answer on the site, and it worked, but there is some characters that I can't find how to encode and iis doesn't like at all The original ...
1
vote
3answers
214 views

Tell nginx to SSL encrypt specific PHP documents

I have set up my server with the following settings: server { server_name www.example.com listen 443; listen 80; location /login\.php { rewrite ^(.*) ...
1
vote
1answer
267 views

URL ReWrite for Windows Server (IIS)

Yesterday, I asked for help on urlrewrite - Ulrich Palha helped me to solve the problem. His solution is working great on Linux server using .htaccess, and I appreciate his help, but the solution ...
1
vote
0answers
397 views

lighttpd 1.5 reverse-proxy to trac

I'm running lighttpd 1.5 freshly compiled off svn. I have a trac daemon listening on port 8000 and I want to proxy all requests matching ^http://xx.xx.xx.xx/trac(*.) to that daemon. Here is what it ...
1
vote
2answers
446 views

Infinite loop when putting rewrite into Directory context in Apache

I want to redirect www.example.com/foo to www.example.com/bar/index.php/foo So I have the rule (mod_rewrite) <Location /> RewriteEngine on RewriteRule /(.*) /bar/index.php/$1 [L] ...