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
18
votes
3 answers

Use Mod_Rewrite to Rewrite ROOT to Another Path

Note: I have tried the suggestions under this question but they either don't work or give me an infinite redirect loop error. I have the following in my .htaccess file: Options +FollowSymLinks RewriteEngine On …
leek
  • 11,803
  • 8
  • 45
  • 61
18
votes
2 answers

Nginx URL masking to a different domain

There's a few similar questions on SO, but none exactly mine, and I've had no luck trying to adapt their answers so far. I want to map the URL http://sub.example.com to https://123.12.12.12/path, such that the browser still shows the URL…
kennysong
  • 2,044
  • 6
  • 24
  • 37
18
votes
1 answer

Using IIS Rewrite to add HttpOnly Flag To Cookies Not Working

I found numerous examples of adding the HttpOnly to my cookies but it does not work for me and I am not sure why. All the examples I found were the same and I copied this one from one of the posts that I had found. I am using .NET 3.5 under IIS 7.0.…
mrhoades
  • 181
  • 1
  • 1
  • 5
18
votes
4 answers

Can't change IIS response code with URL Rewrite outbound rule

I'm trying to set up an IIS URL Rewrite rule to match 403 responses as a result of someone attempting to browse to a directory when directory browsing is disabled. I want to then redirect them to the usual ASP.NET custom errors page I have defined…
Troy Hunt
  • 20,345
  • 13
  • 96
  • 151
18
votes
3 answers

ASP.NET MVC + IIS7 + FireFox : trailing slash in URL

Note: I have done hours of digging for the answer, and couldn't find one. I have an ASP.NET MVC (2.0) application, hosted on IIS7 (integrated mode). When GET request is made to /Toons/List - I get a redirect (302) to /Toons/List/ which is…
THX-1138
  • 21,316
  • 26
  • 96
  • 160
18
votes
6 answers

jQuery on the fly URL shortener

I'm looking for an on the fly URL shortener much like how tweetdeck works. I have found many jQuery and general javascript plugins that take a url and run it through a shortening service such as bit.ly when a button is pressed. However, I have not…
Jason
  • 17,276
  • 23
  • 73
  • 114
18
votes
1 answer

How to rewrite Location response header in a proxy setup with Apache?

I have a primary proxy which sends requests to a secondary proxy on which OpeenSSO is installed. If the OpenSSO agent determines that the user is not logged in, it raises a 302 redirect to the authentication server and provides the original…
xeonman9000
  • 181
  • 1
  • 1
  • 6
17
votes
4 answers

How do I get the last segment of URL using regular expressions

I have a URL: www.domain.com/first/second/last/ How do I get the last term between slashes? i.e. last using regular expressions? Please note that the URL could just be: www.domain.com/last/ Or: www.domain.com/first/second/third/fourth/last/ I…
Matt
  • 251
  • 1
  • 5
  • 9
17
votes
2 answers

RewriteCond for url with parameters

I've got a problem to rewrite an url. I want this : http://www.foo.com/test.php?u=s1&id=12345&img=12 to http://app.foo.com/12345-s1-12.test First parameter u is a string, parameters id and img are integers. I've started with something like that…
CrazyMax
  • 781
  • 1
  • 11
  • 24
17
votes
3 answers

Removing .aspx from pages using rewriteModule?

I'm using ASP .NET rewriteModule to rewrite http://example.com to http://www.example.com.
Then i have this inside .
Danpe
  • 18,668
  • 21
  • 96
  • 131
17
votes
2 answers

In the IIS7 URL Rewrite module, can I specify in a redirect rule to not apply to http-post requests?

In IIS7 URL Rewrite module, can I specify in a redirect rule to not apply to http-post requests? I am using the templates provided by Microsoft to lowercase all urls and to append a trailing slash. However I have a AJAX post requests that don't meet…
Blegger
  • 4,272
  • 4
  • 30
  • 36
17
votes
5 answers

Incorrect Url.Action when URL rewrite is used

I get an incorrect URL from the Action method when I use a URL rewrite. I have this rewrite rule in web.config:
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
17
votes
3 answers

Apache rewrite - get original URL in PHP

I have a rewrite in nginx or Apache for this address: http://domain.com/hello to a script like http://domain.com/test.php&ref=hell How can I access this rewritten URL in PHP? Because, if I use $_SERVER['REQUEST_URI'] of course I…
swamprunner7
  • 1,321
  • 6
  • 16
  • 25
17
votes
5 answers

React Router + iis? How to enable routing

I am using react-router and have put it in it, but I noticed that when I start at the landing page and go through all my routes it works. If I just type in a path url I get a 404. Am I guessing this has something to do with the server not knowing…
chobo2
  • 83,322
  • 195
  • 530
  • 832
17
votes
2 answers

htaccess rewrite breaks relative paths

I have an htaccess file which maps http://www.myserver.com/home/ to http://www.myserver.com/index.php?section=home This part works fine. The issue I am facing now is, all my images and css reside in a sub-folder named assets, i.e.…
irot
  • 592
  • 1
  • 6
  • 13