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
42
votes
1 answer

.htaccess RewriteRule to preserve GET URL parameters

I'm having issues keeping the parameters of the URL working after an .htaccess URL rewrite. My .htaccess rewrite is as follows: RewriteEngine on RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2 Which…
Enkay
  • 1,898
  • 6
  • 24
  • 35
42
votes
7 answers

How can I include special characters in query strings?

URL http://localhost/mysite/mypage?param=123 works fine. However, if I want to put some special characters in param, like ?, /, \, then the URL becomes http://localhost/mysite/mypage?param=a=?&b=/ or…
KentZhou
  • 24,805
  • 41
  • 134
  • 200
41
votes
2 answers

DDD, Anti Corruption layer, how-to?

At the moment, we have to build an application which is based on a legacy one. Code for that old application should be thrown away and rewritten, but as it usually goes - instead of rewriting it, we need to base something new on it. Recently, we…
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
41
votes
7 answers

Remove HTML or ASPX Extension

In a hosted IIS7 environment, I am looking for the simplest way to use extension-less file names. Simply I have the following pages: index.html (or .aspx) --> example.com gallery.html --> example.com/gallery videos.html -->…
roadsunknown
  • 3,190
  • 6
  • 30
  • 36
41
votes
4 answers

Rewriting URLs from https:// to http:// in IIS7

I'm trying to rewrite urls from the form: https://example.com/about to the form http://example.com/about using IIS7 URL rewriting:
Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
40
votes
7 answers

Nginx rewrite non-www-prefixed domain to www-prefixed domain

I see the Nginx HttpRewriteModule documentation has an example to rewrite a www-prefixed domain to a non-www-prefixed domain: if ($host ~* www\.(.*)) { set $host_without_www $1; rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains…
saltycrane
  • 6,541
  • 6
  • 34
  • 43
39
votes
2 answers

RewriteRule Error: Bad flag delimiters

Using this RewriteRule in my .htaccess file I'm getting RewriteRule: Bad flag delimiters which is returning a 500 error in the browser. Can anyone point me in the right direction please. Thanks. RewriteEngine On RewriteCond %{HTTP_HOST}…
Gareth Daine
  • 4,016
  • 5
  • 40
  • 67
39
votes
4 answers

Apache 301 Redirect and preserving post data

I have implemented SEO URLs using Apache 301 redirects to a 'redirect.cfm' in the root of the website which handles all URL building and content delivering. Post data is lost during a 301 redirect. Unable to find a solution so far, have tried…
Daniel Cook
  • 1,033
  • 1
  • 9
  • 19
38
votes
8 answers

How to normalize a URL in Java?

URL normalization (or URL canonicalization) is the process by which URLs are modified and standardized in a consistent manner. The goal of the normalization process is to transform a URL into a normalized or canonical URL so it is possible to…
dfrankow
  • 20,191
  • 41
  • 152
  • 214
37
votes
2 answers

When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"?

Can /etc/hosts be used instead of resolver when using proxy_pass? I need to perform a proxy_pass to the same nginx machine. Is there a way to resolve the domains using the machine's /etc/hosts file instead of specifying a DNS server thru the…
Ianthe the Duke of Nukem
  • 1,721
  • 2
  • 20
  • 37
37
votes
2 answers

IIS URL Rewrite https rule ignoring localhost

I'm trying to write a URL rewrite rule to force a HTTPS connection. This should always happen except when a request is using localhost (e.g. http://localhost/mysite). The rule is configured as following:
One of many
  • 547
  • 1
  • 4
  • 8
36
votes
3 answers

What is the WCF equivalent of HttpContext.Current.Request.RawUrl?

I've got some RESTful services running in a pure WCF context (i.e. ASP.NET compatibility is not enabled, and thus there is no HttpContext.Current object available). The URLs to the services are rewritten at the start of the request using an…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
36
votes
3 answers

ASP.NET URL Rewriting

How do I rewrite a URL in ASP.NET? I would like users to be able to go to http://www.website.com/users/smith instead of http://www.website.com/?user=smith
GateKiller
  • 74,180
  • 73
  • 171
  • 204
35
votes
2 answers

RewriteRule Last [L] flag not working?

php_flag display_errors 1 php_value auto_prepend_file init.php RewriteEngine on RewriteRule ^$ /id/authenticate [R] RewriteRule ^login_openid$ /id/login_openid.php [QSA,L] RewriteRule ^authenticate$ /id/authenticate.php [QSA,L] RewriteRule…
The Surrican
  • 29,118
  • 24
  • 122
  • 168
35
votes
1 answer

.NET URI: How can I change ONE part of a URI?

Often I want to change just one part of a URI and get a new URI object back. In my current dilemma, I want to append .nyud.net, to use the CoralCDN. I have a fully qualified URI fullUri. How can I, in effect, do this: fullUri.Host = fullUri.Host +…
John Gietzen
  • 48,783
  • 32
  • 145
  • 190