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
5
votes
1 answer
How to change filename on the fly depending on the title args - nginx rewrite
i am serving .pdf files using nginx web server. and setting filename of .pdf file using rewrite rule , depending on the title args.
what i am trying to do is, add my domain name example.com in the filename
1. if title var contains example.com in it…
user138870
5
votes
1 answer
Nginx rewrite without redirect
I want url domain.com/foo-111 to load contents from directory /bar/111 but not change url.
I created a rewrite rule but instead of loading contents of proper directory, it 301 redirects to domain.com/bar/111
My server config
server {
listen 80;
…

Viacheslav
- 187
- 1
- 3
- 8
5
votes
1 answer
url rewrite, nginx throw 404 errors, nothing in error logs
below rewrite works fine:
rewrite ^/city/restaurants$ /city/listings/restaurants permanent;
but this doesnt work
rewrite ^/city/restaurants$ /city/listings/restaurants last;
rewrite ^/city/restaurants$ /city/listings/restaurants break;
what am i…

Olaf Stavenger
- 123
- 1
- 2
- 8
5
votes
2 answers
Rewrite request from POST to GET with nginx
I've got a backend server that, for various reasons, only processes GET requests. This server is located behind nginx proxy (i.e. all access is done to nginx, which proxies it to the backend with proxy_pass). Is it possible to make nginx rewrite…

StasM
- 163
- 1
- 1
- 7
5
votes
1 answer
Using RewriteMap Lookups in a RewriteCond . Possible?
I am trying the following
RewriteMap lookup "txt:D:/lookup.txt"
RewriteCond %{REQUEST_URI} ^/${lookup}
RewriteRule ^/(.*)/(.*)$ /a/$1/b/$2.html [PT,L]
I am trying to compare if the request path is starting with the valid paths or not.
I have a…

serverliving.com
- 885
- 7
- 15
5
votes
2 answers
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 seems to have "lower" priority:
RewriteRule…

LKM
- 153
- 1
- 5
5
votes
2 answers
Nginx: rewriting https:// to http://
I'm trying to get Nginx to rewrite incoming requests to a site my server prefixed with https:// to http:// (this is because a CMS used on this site forces URIs instead of relative paths -- essentially breaking the whole site by making images,…

user3620306
- 53
- 1
- 1
- 4
5
votes
1 answer
Can a URL Rewrite condition compare two server variables?
I am trying to compare two server variables as part of a URL rewrite condition. But first, some context...
In IIS, if you request http://www.example.com/foo and foo is a directory, IIS sends a 302 "Object moved" redirect to…

MALfunction84
- 161
- 2
- 10
5
votes
1 answer
nginx url rewrite with string substitution
I need to catch if my urls contain a small substr, keep the url as it is and rewrite only that small part, how can I accomplish this?
For example:
http://foobar.com/foo-bar-substrtocatch-baz
should…

ngw
- 1,261
- 3
- 13
- 15
5
votes
1 answer
Nginx rewrite *.html to *.php
I've setup my first Nginx site and the important rewrites are all done. They had to be manual, no rules would possibly have handled it, so I have a raft of rules like this to handle old URLs that might be indexed or bookmarked:
rewrite…

G. Armour Van Horn
- 53
- 1
- 1
- 3
5
votes
1 answer
nginx rewrite URL to redirect only if a cookie is not set
I have two domains www.domain.com and www.domain.com.tw. I want the user to be redirected to the closest server, but if they want to view the other server, they can by clicking a link in the site.
I tried to do it with a cookie, but it doesn't seem…

richard
- 153
- 1
- 3
5
votes
1 answer
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:
https://a-alpha/omber/nms
So I guess what I need is to rewrite requests…

Lukasz
- 472
- 2
- 10
- 18
5
votes
1 answer
Saving website level rewrite rules to applicationHost.config
Is it possible to save rewrite rules configured on the level of a website to the applicationHost.config, while using IIS Manager? (I know how to do that manually)
By default they are saved to Web.config file.
I need it to get rules deployed to other…

Tomek
- 153
- 6
5
votes
1 answer
.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 R=302, I
think), I first got my redirect working at…

Brian Wood
- 161
- 1
- 3
5
votes
3 answers
Redirect http://example.com:12345 to https://example.com:12345 in nginx
I know this must have been answered already, but I have been searching for quite a while, and cannot find the answer. Just not looking in the right place I guess, maybe someone can help me out.
Basically I am running phpmyadmin through SSL on a…

Saif Bechan
- 10,960
- 10
- 42
- 63