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.
Questions tagged [rewrite]
2112 questions
13
votes
4 answers
Different nginx rules based on referrer
I'm using WordPress with WP Super Cache. I want visitors who come from Google (That inlcudes all country specific referrers like google.co.in, google.co.uk and etc.) to see uncached contents.
There are my nginx rules which are not working the way I…
juana
12
votes
1 answer
What is the difference between HTTP_HOST and HTTPS_HOST in apache .htaccess files?
I'm editing an .htaccess file..
In RewriteCondition for RewriteRules, HTTPS_HOST seems to only match urls that are accessed via https:// protocol (ssl). I saw in docs somewhere that it's a T/F variable that indicates if the url was accessed using…

SherylHohman
- 405
- 1
- 5
- 15
12
votes
4 answers
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 to take less than 15 minutes).
During that period,…

Josh
- 287
- 1
- 3
- 8
12
votes
4 answers
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 the TeamCity to appear as https://somesite/teamcity…

Cynicszm
- 121
- 1
- 1
- 4
11
votes
3 answers
Add samesite to cookies using Nginx as reverse proxy
With Nginx as reverse proxy, how do you add samesite=strict or samesite=lax to cookies?

Dr.Haribo
- 213
- 1
- 2
- 6
11
votes
2 answers
Add trailing slash when it's missing in nginx
I'm running Magento on Nginx using this config: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento.
Now I want to 301 all URLs without trailing slash to their counterpart that includes a trailing…
user99559
11
votes
1 answer
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 for file name and the available variables uri,…

Johnta
- 113
- 1
- 1
- 4
11
votes
1 answer
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 ^(.*) http://blog.example.org$1 permanent;
}
Every…

lorem monkey
- 835
- 1
- 7
- 10
11
votes
2 answers
IIS Rewrite, rewrite maps and query strings
Please help me understand rewrite maps, I have this setup:

Martin at Mennt
- 177
- 1
- 2
- 11
10
votes
3 answers
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 ^static/([^/]+)/([^/]+) …

Vegard Larsen
- 285
- 4
- 9
10
votes
1 answer
nginx - specify different index file name for subdirectory
I want the directory index file in the root of my site to be index.html but within a subdirectory /foo I want it to be bar.html
i.e.
/index.html
/foo/bar.html
Also I want requests to /foo or /foo/ or /foo/:anything to resolve to bar.html
Why…

Ade
- 699
- 3
- 10
- 21
10
votes
3 answers
How do I make RewriteCond %{HTTP_COOKIE} match a cookie value exactly?
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]
RewriteCond %{HTTP_COOKIE} its=me [NC]
The last…

Nick
- 4,503
- 29
- 69
- 97
10
votes
2 answers
nginx $uri is url decoded
I am using nginx as reverse proxy and I have 2 rules like:
location ~ ^/indirect {
rewrite ^/indirect(.*) /foobar$1;
}
location ~ ^/foobar {
set $url http://example.com/something/index.php?var1=hello&access=$scheme://$host$uri;
proxy_pass…

Carlos Campderrós
- 773
- 2
- 6
- 17
10
votes
3 answers
Apache: Where to examine the redirection logs?
I have complicated RewriteCond and RewriteRule in one machine. And according to these rules, some of the requests will be redirected to another machine.
So is there any Apache log that shows clearly how the redirection takes place? Because the…

Graviton
- 2,865
- 12
- 42
- 64
9
votes
1 answer
Nginx simple redirect of products from old to new category
I'm making redirects of products from old to new category.
I've managed to make it work with following rule:
rewrite ^/old-category/(.*) /new-category/$1;
But I want to know when should I use "end line" sign $ and what's the difference with it or…

Analogtime
- 93
- 3