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
12
votes
5 answers

Asp.net MVC SEO Friendly URL

I want to implement a SEO friendly URL for my ASP.NET MVC website. Currently i have a URL like: http://www.domain.com/product?id=productid but now i want to rewrite my URL like: http://www.domain.com/productname So please anybody can help me on…
12
votes
4 answers

Show no_picture.png by .htaccess if picture is not exist

I want to show no_picture.png if requested picture does not exists. I should do it with .htaccess. Thanks a lot.
mTuran
  • 1,846
  • 4
  • 32
  • 58
12
votes
1 answer

htaccess redirect all requestes to index.php except sub folder

I have a CMS installed at the root of my domain with the following htaccess: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] This takes care of…
jribeiro
  • 3,387
  • 8
  • 43
  • 70
12
votes
2 answers

IIS URL Rewrite with multiple query string

Im really new in URL Rewriting and trying to rewrite / redirect multiple query but seems not working. Since this is the search result and comes with different filtering the queries may vary. For example is some search we may have the query of…
Jay
  • 1,384
  • 1
  • 17
  • 30
12
votes
1 answer

IIS 7.5 URL Rewrite - Rewrite a Folder from an URL

I use IIS 7.5 and URL Rewrite. I have a website with the following file hierarchy: webroot webroot/LegacySite Both webroot/ and legacy/ are separate App-Folders in IIS. I need to rewrite my URLs so: If a request is…
GibboK
  • 71,848
  • 143
  • 435
  • 658
11
votes
3 answers

How to rewrite the index.php of Codeigniter on Windows Azure

How to remove index.php in codeigniter on Windows Azure and IIS? Can I rewrite the URL for the index.php of Codeigniter without a particular module?
Romain Beuque
  • 159
  • 1
  • 2
  • 9
11
votes
3 answers

Remove .php extensions with .htaccess without breaking DirectoryIndex

I have the following rewrite in my .htaccess file which removes the .php extension from files, converting for example so.com/question.php to so.com/question. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php…
ajcw
  • 23,604
  • 6
  • 30
  • 47
11
votes
3 answers

Mode Rewrite; with/without trailing slash on end of url?

I basically tried this mode_rewrite rule below. It works with a slash on the end but I want it to work whether it has a trailing slash on the end or not. Basically I want it like this as some people see it as normal with a slash on the end and…
PHPLOVER
  • 7,047
  • 18
  • 37
  • 54
11
votes
7 answers

$_GET and URL Rewriting for PHP

How does URL rewriting affect the $_GET parameter for PHP? Say I have a URL like http://example.com/index.php?p=contact and I use $_GET['p'] to tell index.php to serve the contact page. If I use a rewrite rule that converts the URL to…
VirtuosiMedia
  • 52,016
  • 21
  • 93
  • 140
11
votes
3 answers

Append Query String to IIS Rewrite Map

I have a ReWrite Map and I would like to append any query parameters in the requested URL to the rewritten URL. For instance: /page/abc/ ---> /index.cfm?page=abc (works) /page/abc/?param1=111 ---> /index.cfm?page=abc¶m1=111 (doesn't…
Philip P.
  • 111
  • 1
  • 1
  • 4
11
votes
5 answers

Firebase: Pass url Param in URL Rewrite

For the code examples in the firebase docs, it says to initiate a url rewrite like so: "hosting": { // Add the "rewrites" section within "hosting" "rewrites": [ { "source": "**", "destination":…
JamesG
  • 1,552
  • 8
  • 39
  • 86
11
votes
3 answers

Rewriting a recursive function without using recursion

I'm rewriting some existing code in a setting where recursive calls are not easily implemented nor desired. (And in Fortran 77, if you must know.) I've thought about making a stack from scratch to keep track of the calls needed, but this seems…
Old McStopher
  • 6,295
  • 10
  • 60
  • 89
11
votes
1 answer

UrlRewrite condition based on custom HTTP header

I'm trying to configure a rule in UrlRewrite that has 2 conditions: HTTP header HTTP_HOST needs to match a certain domain (api.contoso.com) A custom HTTP header x-app-version needs to be present in the HTTP request based on this info, I'd like to…
user80498
  • 735
  • 1
  • 7
  • 15
11
votes
3 answers

How can I determine if a URL redirects in PHP?

I saw someone ask a question about detecting if a URL redirects from groovy and perl but couldn't find anything on PHP. Anyone know of somewhere I could find that code that does this?
GeoffreyF67
  • 11,061
  • 11
  • 46
  • 56
11
votes
2 answers

NGINX: remove part of url permanantly

I have redesigned a website and changed the url formats too. Now i need to change the old url to new one. Here is my old url: http://www.example.com/forum/showPost/2556/Urgent-Respose The new url will…
Pulkit Sharma
  • 264
  • 1
  • 2
  • 18