Questions tagged [url-rewriting]

A URL rewrite engine is software that modifies a web URL's appearance (URL rewriting). Rewritten URLs are used to provide shorter and more relevant-looking links to web pages, to route users from obsolete URLs to replacements, or to simplify the format of the URL for human readability. The technique adds a degree of separation between the files used to generate a web page and the URL that is presented to the world.

A URL rewrite engine, part of a web server's URL-to-filename mapping engines, is software that modifies a web URL's appearance (URL rewriting). Rewritten URLs (sometimes known as short, fancy URLs, or search engine friendly - SEF) are used to provide shorter and more relevant-looking links to web pages, to route users from obsolete URLs to replacements, or to simplify the format of the URL for human readability. The technique adds a degree of separation between the files used to generate a web page and the URL that is presented to the world. It is integral in frameworks that route all URI requests through a routing script or a controller.

Useful links

  1. and its tag-wiki for some examples regarding the most widely-used implementation for the Apache web server.
  2. and its tag-wiki for an implementation for java/j2EE technology.
20479 questions
14
votes
1 answer

Microsoft rewriting module - Force www on URL Or remove www from URL

I have a shared hosting plan with Windows Server 2008 and IIS7.5, and there is Microsoft rewriting module installed and enabled.
Mahdi Ghiasi
  • 14,873
  • 19
  • 71
  • 119
14
votes
1 answer

RewriteCond to skip rule if file or directory exists

I am trying to adjust my htacess file to skip the rewrite rule if the file or directory exists, but when the file exists, it changes the URL to something different. I don't know why this is happening. Here is my htaccess file: RewriteEngine…
Nathan Wittmaier
  • 143
  • 1
  • 1
  • 4
13
votes
4 answers

How to rewrite an URL on a JBoss server?

I would like to redirect/rewrite this two kinds of URLs: mydomain.com -> newdomain.com mydomain.com/specificPage -> newdomain.com/newSpecificPage mydomain.com/anyOtherPage -> mydomain.com/anyOtherPage (no redirect here) So I just want to redirect…
Syl
  • 131
  • 1
  • 2
  • 4
13
votes
3 answers

.htaccess URL Rewrite to Subdirectory

What is the best method to rewrite anything below "/some/subdir" to "/some/subdir/projects" like from this: http://www.mydomain.com/some/subidr/test/ ... to this: http://www.mydomain.com/some/subdir/projects/test/ I found a similar question…
Wilco
  • 32,754
  • 49
  • 128
  • 160
13
votes
1 answer

htaccess rewrite rule with escaped ampersand in $_GET fails

I am encountering a problem with a get parameter in conjunction with a htaccess rewrite rule. Below is the urlencode()'ed link; the rewrite rule I use to redirect to index.php, and lastly, a print_r($_GET) on the index.php. As you can see, the…
kontur
  • 4,934
  • 2
  • 36
  • 62
13
votes
1 answer

How to get reverse proxy server's HTTP_HOST in outbound rules of URL Rewrite w/ ARR

I'm using URL Rewrite and Application Request Routing in IIS 7.5 to set up a reverse proxy for a couple of blogs that need to be integrated into existing websites. Multiple domains are bound to one website in IIS, and each one will get a blog that…
joelmdev
  • 11,083
  • 10
  • 65
  • 89
13
votes
2 answers

Missing ARR Rewrite option in Failed Request Tracing

I am using Application Request Routing 3.0 with IIS's failed request tracing. I am having issues with my rewrite rules so I wanted to troubleshoot it. I wanted to follow the steps below to enable IIS logging of rewrite rules but the option doesn't…
MichaelChan
  • 1,808
  • 17
  • 34
13
votes
11 answers

Is this the "one in ten" time to rewrite?

I'm very much against rewriting an application if it can be avoided. I understand the rule that 9 times out of 10, it's better to refactor, but I'm in a situation where it might be the one time in ten, and I'm looking to find that line. The current…
13
votes
11 answers

Rewrite or repair?

I'm sure you have all been there, you take on a project where there is a creaky old code base which is barely fit for purpose and you have to make the decision to either re-write it from scratch or repair what already exists. Conventional wisdom…
John Channing
  • 6,501
  • 7
  • 45
  • 56
13
votes
3 answers

Hiding true database object ID in url's

What would be useful solutions for hiding true database object ID in URL for security purposes? I found that one of the solutions would be: 1) Using hashids open source project 2) Using something like same old md5 on creation of the object to…
Dan Mironis
  • 711
  • 6
  • 14
13
votes
4 answers

How do you remove invalid characters when creating a friendly url (ie how do you create a slug)?

Say I have this webpage: http://ww.xyz.com/Product.aspx?CategoryId=1 If the name of CategoryId=1 is "Dogs" I would like to convert the URL into something like this: http://ww.xyz.com/Products/Dogs The problem is if the category name contains foreign…
Anthony
  • 7,210
  • 13
  • 60
  • 70
13
votes
4 answers

Change parent window URL from iFrame

I'm having a parent site at myurl.com from which I load an iFrame in a an overlay/modal layer. In the iFrame I have different tabs with steps 1-5 containing different form elements - in other words it's a kind of checkout flow. Each tab is located…
McAsh
  • 215
  • 2
  • 4
  • 11
13
votes
3 answers

What's the difference between Request.Url.Query and Request.QueryString?

I have been tracking down a bug on a Url Rewriting application. The bug showed up as an encoding problem on some diacritic characters in the querystring. Basically, the problem was that a request which was basically /search.aspx?search=heřmánek was…
Bruce Chapman
  • 1,227
  • 3
  • 12
  • 19
13
votes
3 answers

External links URL encoding leads to '%3F' and '%3D' on Nginx server

I got a problem with my server. I got four inbound links to different sites of my dynamic webpage which look something like this: myurl.com/default/Site%3Fid%3D13 They should look like this: myurl.com/default/Site?id=13 I do know that those %3F…
user3082653
  • 71
  • 1
  • 1
  • 10
13
votes
2 answers

How to rewrite domain.com to www.domain.com with HAProxy?

We have 1 loadbalancer with 3 members behind it: main balancer: www.website.com members: web1.website.com, web2.website.com and web3.website.com Currently we are using nginx on the loadbalancer, but we want to replace it with HAProxy. Nginx…
Arjan
  • 193
  • 1
  • 3
  • 9