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
93
votes
11 answers

Header set Access-Control-Allow-Origin in .htaccess doesn't work

I can't figure out why my .htaccess header settings doesn't work. My .htaccess file content: Header set Access-Control-Allow-Origin * Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" Header always set…
user1401592
  • 939
  • 1
  • 7
  • 4
92
votes
8 answers

Is it possible to rewrite a status code with Charles Proxy?

I'm using Charles Proxy to rewrite a response from an API for testing purpose. If I set a breakpoint, I am allowed to completely rewrite the raw response as I wish. However, if I want to automate it via the "Rewrite" tool, I'm stuck, it seems that…
Thomas
  • 1,360
  • 1
  • 9
  • 15
88
votes
9 answers

.htaccess rewrite subdomain to directory

Is it possible to use .htaccess to rewrite a sub domain to a directory? Example: http://sub.domain.example/ shows the content of http://domain.example/subdomains/sub/
Erik Djupvik
  • 1,187
  • 1
  • 10
  • 13
76
votes
8 answers

Rewrite all requests to index.php with nginx

In my apache configuration I have the following simple rewrite rule which unless file exists will rewrite to index.php on the urls you never see the file extension (.php) how can I rewrite this in nginx? # # Redirect all to…
ptheofan
  • 2,150
  • 3
  • 23
  • 36
75
votes
13 answers

urlencoded Forward slash is breaking URL

About the system I have URLs of this format in my project:- http://project_name/browse_by_exam/type/tutor_search/keyword/class/new_search/1/search_exam/0/search_subject/0 Where keyword/class pair means search with "class" keyword. I have a common…
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144
72
votes
5 answers

REST - supporting multiple possible identifiers

For the site I am working on, we are in the process of improving our URLs for one type of resource - specifically, moving away from numerical IDs toward unique, descriptive strings. A similar example would be switching from identifying users by…
Kelly Ellis
  • 1,081
  • 1
  • 11
  • 13
69
votes
11 answers

Add slash to the end of every url (need rewrite rule for nginx)

I try to get an / to every urls end: example.com/art should example.com/art/ I use nginx as webserver. I need the rewrite rule for this.. For better understanding check this: http://3much.schnickschnack.info/art/projekte If u press on a small…
Gomez
  • 1,211
  • 2
  • 11
  • 10
64
votes
11 answers

How can I remove file extension from a website address?

I am designing a website. I want my website address to look like the following image: I don't want my website to look like http://something.example/profile.php. I want the .php extension to be removed in the address bar when someone opens my…
sumit
  • 10,935
  • 24
  • 65
  • 83
63
votes
9 answers

Url rewrite does not install on windows 10 IIS 10

I need the Url Rewrite module on my IIS But it does not install and says that I need at least IIS7
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
63
votes
2 answers

Apache: edit to .conf file produces "Invalid command 'Header'"

In Magento CE, I'd like to install an add-on to Extendware Page Cache called Lightening Cache. It requires editing the Apache configuration inside the virtual host definition for the site, by adding: RewriteEngine On RewriteMap ewpchash…
Steve
  • 2,066
  • 13
  • 60
  • 115
60
votes
3 answers

IIS URL Rewrite and Web.config

I don't understand anything about IIS, but am trying to solve this problem of redirecting all visitors to example.com/page to example.com/page.html
J. Martin
  • 1,683
  • 2
  • 17
  • 33
57
votes
1 answer

NGINX - Return 301 vs Rewrite

I use NGINX in my dedicated server. I've a question about the return and rewrite 301. Rewrite 301: rewrite ^ http://xxx.xxxxx.net/xx-xxx/$request_uri? permanent; Return 301: location ~ redirect-this/?$ { return 301…
Ferrmolina
  • 2,737
  • 2
  • 30
  • 46
54
votes
6 answers

Best option for Session management in Java

Best way managing session in Java. I heard that cookies are not reliable option for this as they gets stored into browser and can be accessed later on? Is this correct? If possible please come up with the answers with the coding example. Which is…
Sachin
  • 20,805
  • 32
  • 86
  • 99
53
votes
4 answers

Why do I need to use http.StripPrefix to access my static files?

main.go package main import ( "net/http" ) func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.ListenAndServe(":8080", nil) } Directory…
Dante
  • 10,722
  • 16
  • 51
  • 63
52
votes
4 answers

Rewrite URL after redirecting 404 error htaccess

So I know this may seem a little strange but I for sake of consistency, I would like all my urls to appear in this form: http://example.com/page/ So far I have gotten the regular pages working but I cannot seem to get the error pages working…
godismyjudge95
  • 922
  • 1
  • 9
  • 15