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
51
votes
8 answers

Can I use commas in a URL?

I typically use URL rewriting to pass content IDs to my website, so this Foo.1.aspx rewrites to Foo.aspx?id=1 For a specific application I need to pass in multiple IDs to a single page, so I've rewritten things to accept this: …
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
51
votes
5 answers

Replacing IIS rewrite rules in web.config transform

I have some IIS rewrite rules that I want to vary by environment. The development rewrite rules are in the web.config file, then at the end of the web.test.config file I have: ...Some app settings tranforms here …
LDJ
  • 6,896
  • 9
  • 52
  • 87
50
votes
7 answers

IIS URL Rewriting vs URL Routing

I was planning to use url routing for a Web Forms application. But, after reading some posts, I am not sure if it is an easy approach. Is it better to use the URL Rewrite module for web forms? But, it is only for IIS7. Initially, there was some buzz…
Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
50
votes
8 answers

web.config redirect non-www to www

I need to redirect non-www URLs to www URL for both HTTP and HTTPS URLs. I tried following rules in web.config.
Anand
  • 1,670
  • 1
  • 15
  • 23
50
votes
8 answers

Is this the best way to rewrite the content of a file in Java?

I want to rewrite the contents of a file. What I have thought of so far is this: Save the file name Delete the existing file Create a new empty file with the same name Write the desired content to the empty file Is this the best way? Or is there a…
Ankur
  • 50,282
  • 110
  • 242
  • 312
49
votes
1 answer

logging proxy activity in nginx

I am using rewrite and proxy_pass and I am having some intermittent issues with the site I am proxying said rewrites too. Is there a means to log the proxy activity so I that I can debug this problem?
hinder90
  • 571
  • 1
  • 4
  • 7
49
votes
8 answers

How to hide the .html extension with Apache mod_rewrite

I have a small number of static sites where I simply want to hide the .html extension: the URL /foo fetches the static file /foo.html the browser still displays the URL /foo The client can then send out bookmarks in the style example.com/foo…
Dave Everitt
  • 17,193
  • 6
  • 67
  • 97
48
votes
18 answers

Python Performance - have you ever had to rewrite in something else?

Has anyone ever had code in Python, that turned out not to perform fast enough? I mean, you were forced to choose another language because of it? We are investigating using Python for a couple of larger projects, and my feeling is that in most…
Dutch Masters
  • 1,429
  • 17
  • 19
48
votes
2 answers

htaccess 301 redirect - Remove query string (QSA)

I've been struggling with some htaccess redirects. I just spent some time reading and searching on stack and couldn't get an anwser that works with my scenario. I'm in the process of making the 301 redirect for an old client website to a new one.…
newpoison
  • 914
  • 2
  • 8
  • 20
48
votes
9 answers

How to change the URL from "localhost" to something else, on a local system using wampserver?

On a Windows machine, there's a system running on the local wampserver, but while the application is running on localhost, the URL says otherwise. While I would expect the URL to be like this based on the directory…
user961627
  • 12,379
  • 42
  • 136
  • 210
46
votes
4 answers

Java code/library for generating slugs (for use in pretty URLs)

Web frameworks such as Rails and Django has built-in support for "slugs" which are used to generate readable and SEO-friendly URLs: Slugs in Rails Slugs in Django A slug string typically contains only of the characters a-z, 0-9 and - and can hence…
knorv
  • 49,059
  • 74
  • 210
  • 294
44
votes
2 answers

IIS url rewrite role except some urls

I got this rule in URL rewrite that rewrites every request to the site using HTTP to HTTPS
dotmido
  • 1,374
  • 3
  • 13
  • 29
43
votes
2 answers

Where does nginx store the rewrite_log?

When you turn on the nginx rewrite log with rewrite_log on;, where does the system actually log that info? It doesn't seem to be in the documentation, and a decent search through google doesn't turn anything up. I have also tried enabling and…
kenny
  • 3,439
  • 3
  • 26
  • 31
43
votes
3 answers

Rewrite rule to HTTPS except when on localhost

I am using the answer given here as the basis for trying to add a rewrite rule to my web.config file. I want it to match any url that is not running on localhost in order to force https. Here is what I have right now:
Yaakov Ellis
  • 40,752
  • 27
  • 129
  • 174
43
votes
2 answers

"OR" Flag in .htaccess mod_rewrite

Just found this .htaccess rewrite code RewriteEngine on RewriteCond %{HTTP_HOST} ^my.domain.com$ [NC,OR] RewriteCond %{REQUEST_URI} !public/ RewriteRule (.*) /public/$1 [L] And I was wondering what was the purpose of the "OR" flag. Already checked…
gabriel-kaam
  • 1,230
  • 1
  • 12
  • 13