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

Translating Perl to Python

I found this Perl script while migrating my SQLite database to mysql I was wondering (since I don't know Perl) how could one rewrite this in Python? Bonus points for the shortest (code) answer :) edit: sorry I meant shortest code, not strictly…
Jiaaro
  • 74,485
  • 42
  • 169
  • 190
21
votes
6 answers

Rewriting nginx for pushState-URL's

I am trying to get nginx to work with my pushState-based URI handling that backbone.js manages for me in an Javascript app. Right now accessing URI's with one level, eg. example.com/users works well, but not two-level or deeper URI's, such as…
Industrial
  • 41,400
  • 69
  • 194
  • 289
21
votes
7 answers

Is it possible to have the url change while you scroll down a single page

Is it possible to have the url change while you scroll down a single page with ajax? I have a website all on one page and want to have this effect. example: www.blablabla.com/blog user scroll down... www.blablabla.com/blog/entry-name I know about…
eptype
  • 211
  • 1
  • 2
  • 4
21
votes
1 answer

URL Rewrite based on User-Agent header

You can optimize content by delivering only Open Graph meta tags to the crawler and only the content itself to regular users. [source] I'm trying to identify Facebot(Facebook's crawler) so I can serve it the meta tags. To do that, I'll need to be…
21
votes
3 answers

Should I use Url.Content() or ResolveUrl() in my MVC views?

When building code like this: or " /> Should I use Url.Content or ResolveUrl()? What's the difference?
Michael Haren
  • 105,752
  • 40
  • 168
  • 205
20
votes
2 answers

Is there a url rewriting engine for Tomcat/Java?

How can we provide URL-Rewriting support for Tomcat/Java ? mod_rewrite provides this functionality for Apache and can modify URLs even before they reach the handler (e.g. PHP). Is there a similar tool in Java/Tomcat ? To be more specific we need…
anshuman
20
votes
4 answers

nginx server configuration: subdomain to folder

I migrated from Apache 2 to nginx and I've got problems to handly my subdomain control. What I want: When x.domain.tld is requested, internally rewrite to domain.tld/x The problem I've got is that nginx always redirects the page by telling the…
quotient7
  • 201
  • 1
  • 2
  • 3
20
votes
8 answers

How to replace underscores in codeigniter url with dashes?

I would like to know the simplest solution to changing the underscores of my codeigniter urls to dashes, for seo reasons. My controllers look like: public function request_guide() { ...Load view etc... } So to browse to this page I would have to go…
hairynuggets
  • 3,191
  • 22
  • 55
  • 90
20
votes
2 answers

Rewrite rule error: HTTP Error 500.50 - URL Rewrite Module Error. The expression "https://abc.com/{R:1}" cannot be expanded

Whenever someone makes request over HTTP protocol I rewrite the url to make it HTTPS. This is the code in web.config:
TCM
  • 16,780
  • 43
  • 156
  • 254
20
votes
6 answers

How to execute a PHP web page without the .php extension in the URL?

Sorry for noob question, can't understand from what I should search. I'm making a site with that page product.php?id=777 I'd like it to be product/777 Thank you!
Tuco
  • 857
  • 2
  • 12
  • 26
20
votes
3 answers

How to rewrite target url within an AWS ALB Ingress Controller?

In a classic Kubernetes Nginx ingress I know that it is possible to rewrite target url based on a specific regex by appling this annotation nginx.ingress.kubernetes.io/rewrite-target: /$1 But this annotation does not work in AWS ALB ingress. Does…
20
votes
2 answers

.htaccess with or without slash

What do I need to do to the following rewrite rule to make it so it works whether or not their is a slash at the end of the URL? ie. http://mydomain.com/content/featured or http://mydomain.com/content/featured/ RewriteRule ^content/featured/…
sbuck
  • 1,846
  • 4
  • 24
  • 40
20
votes
9 answers

http to https rewrite too many redirect loops IIS 7

I have application which I have hosted in IIS 7.0. Where I have to make sure that it works only on HTTPS and not on HTTP so I have included below rule in my root config.
Prashant Mohite
  • 758
  • 2
  • 7
  • 19
20
votes
2 answers

Modifying headers with IIS7 Application Request Routing

I'm using IIS7 Application Request Routing in front of Tomcat as a replacement for ISAPI redirection. The basic reverse proxy function is working well, but I don't have enough information in the final request headers. My application exists on…
Adrian Cox
  • 6,204
  • 5
  • 41
  • 68
20
votes
7 answers

Magento URLs other than home page do not work without index.php

My magento is installed on Ubuntu Linux under /var/www/magento . This question looks like some of the questions in the archives but is acutally somewhat different. When I installed Magento on Ubuntu Linux I enabled Apache mod_rewrite URL…
user1527429
  • 727
  • 5
  • 10
  • 17