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

Rewrite path only if file/folder does not exist

I am using the IIS Rewriter module with my web.config, and would like to redirect certain requests for content in a subdirectory only if there isn't an actual folder/file that already matches the request. How can I do this?
MarathonStudios
  • 3,983
  • 10
  • 40
  • 46
14
votes
8 answers

Remove last character in a path string if it is a slash

I'm doing some url rewriting in PHP and need to find URLS with a slash at the end and then do a 301 redirect. I thought there'd be a simple PHP function to find last string, but I couldn't find anything. First instincts make m think I need to use…
Bob Cavezza
  • 2,810
  • 7
  • 38
  • 56
14
votes
3 answers

Prevent NGINX to remove the port

I want to keep the ServerName and Port dynamicly on my rewrite: Lets say the Firewall redirect port 8081 to 80. So, if i access the webserver for example with "192.168.1.123/frontend" or "my.domain.tld:8081/frontend" i should be redirect to…
Gurkengewuerz
  • 143
  • 1
  • 1
  • 7
14
votes
3 answers

IIS URL Rewrite : 403 - Forbidden: Access is denied

I installed IIS URL Rewrite 2.0 and add a rule to redirect all http links to https. Here is my Web.Config Code:
Abdul
  • 2,002
  • 7
  • 31
  • 65
14
votes
3 answers

Server.Transfer vs. Context.RewritePath

I understand they both don't change the URL that the client sees. Is there anything in them that makes one of them preferable over the other? I'm planning to use it in the Application_BeginRequest in Global.asax, but also in regular aspx page.
Lea Cohen
  • 7,990
  • 18
  • 73
  • 99
14
votes
2 answers

IIS redirect url for virtual directory

How can I set a redirect url for a virtual directory in IIS 7.0? I have installed the latest url rewrite module 2.x. I can explain my problem with an example: I have a website on my IIS 7.0 server, www.mysite.com. I decided to create a virtual…
Jouni
  • 141
  • 1
  • 1
  • 4
14
votes
1 answer

What is Loglevel debug?

My error.log file for my site says Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer:…
Ben
  • 60,438
  • 111
  • 314
  • 488
14
votes
1 answer

Remove Trailing Slash from Magento URL

I understand there are many answered questions on this particular issue but I haven't found anything specific to Magento, and I was wondering if changing the .htaccess file will have repercussions in my Magento store. Basically I have links in my…
Harry
  • 371
  • 2
  • 5
  • 15
14
votes
3 answers

Remove .html and .php extensions with .htaccess

How do I remove the file type from my webpages without creating a new directory and naming the file index.php. I want http://example.com/google.html to http://example.com/google. How would I go about doing this. PS: I tried looking at some other…
SimplePi
  • 95
  • 1
  • 4
  • 15
14
votes
2 answers

Setting up URL Rewrite rule for a specific domain

For local dev testing, I need to catch all requests to www.somedomain.com/XXX (where X is the path), and send them on to localhost/somevdir/XXX. I've added this to my HOSTS file (c:\windows\system32\drivers\etc): 127.0.0.1 www.mydomain.com Then,…
Matt Roberts
  • 26,371
  • 31
  • 103
  • 180
14
votes
2 answers

nginx rewrite all wildcard subdomains to www.site.com

Using nginx, I want to redirect all subdomains of example.com to www.example.com. I have seen redirects here to redirect non-www to www or vise versa, but I also want www2.site.com blabla.site.com to be redirected. I have a wildcard dns for the…
user2143308
  • 141
  • 1
  • 1
  • 4
14
votes
11 answers

What Url rewriter do you use for ASP.Net?

I've looked at several URL rewriters for ASP.Net and IIS and was wondering what everyone else uses, and why. Here are the ones that I have used or looked at: ThunderMain URLRewriter: used in a previous project, didn't quite have the…
travis
  • 35,751
  • 21
  • 71
  • 94
14
votes
2 answers

django getting the absolute path of a FileField

I am trying to retrieve the absolute path (starting with http://) while calling a FileField at the template. How can I achieve this ? ie: {{fl.uploadedfile}} -> returns relative path like media/uploads/ while I want This Cheers
Hellnar
14
votes
5 answers

How to find out programmatically if a web server instance supports url rewrite

What I want to ask is if there is a way to find out if a web-server instance has URL Rewriting enabled. I need this in order to be able to instantiate the correct type of URL handler. Theoretically you know in advance if you have it enabled or not…
Marius Or.
  • 374
  • 4
  • 10
14
votes
9 answers

How to do URL re-writing in PHP?

I am trying to implement URL rewriting in my PHP application. Can someone share a step by step procedure of implementing URL rewriting in PHP and MySQL? In my application I want to implement following URL rewriting, I want to redirect 1.…
djmzfKnm
  • 26,679
  • 70
  • 166
  • 227