This link has been bookmarked by 269 people . It was first bookmarked on 24 Apr 2006, by someone privately.
-
18 Oct 16
-
02 Mar 15
-
09 Jan 13
-
27 Aug 12
-
13 Jul 12
-
03 May 12
-
28 Jan 12
-
06 Nov 11
-
05 Nov 11
borferApache
-
26 Oct 11
-
21 Jul 11
-
15 Mar 11
-
12 Mar 11
-
16 Feb 11
Joseph MorninReadable URLs are nice. A well designed website will have a logical file system layout, with smart folder and file names, and as many implementation details left out as possible. In the most well designed sites, readers can guess at filenames with a high level of success.
However, there are some cases when the best possible information design can’t stop your site’s URLs from being nigh-on impossible to use. For instance, you may be using a Content Management System that serves out URLs that look something like
http://www.example.com/viewcatalog.asp?category=hats&prodID=53
This is a horrible URL, but it and its brethren are becoming increasingly prevalent in these days of dynamically-generated pages. There are a number of problems with an URL of this kind:-
Now we get on to the really useful stuff. The power of
mod_rewritecomes at the expense of complexity. If this is your first encounter with regular expressions, you may find them to be a tough nut to crack, but the options they afford you are well worth the slog. I’ll be providing plenty of examples to guide you through the basics here.Using regular expressions you can have your rules matching a set of URLs at a time, and mass-redirect them to their actual pages. Take this rule;
RewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1This will match any URLs that start with ‘products/’, followed by any two digits, followed by a forward slash. For example, this rule will match an URL like products/12/ or products/99/, and redirect it to the PHP page.
The parts in square brackets are called ranges. In this case we’re allowing anything in the range 0-9, which is any digit. Other ranges would be
[A-Z], which is any uppercase letter;[a-z], any lowercase letter; and[A-Za-z], any letter in either case.
-
-
24 Nov 10
-
07 Nov 10
-
02 Sep 10
-
31 Aug 10
-
24 Aug 10
-
16 Aug 10
Idearium MXThe Apache server’s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user’s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the ‘dirty’ URLs coming from a poor publishing system —...
-
24 Jun 10
-
07 Jun 10
-
15 May 10
-
12 May 10
-
11 May 10
-
30 Mar 10
-
03 Mar 10
-
28 Feb 10
-
07 Feb 10
-
26 Jan 10
-
25 Jan 10
-
22 Jan 10
-
23 Dec 09
-
18 Dec 09
-
03 Dec 09
-
10 Nov 09
-
06 Nov 09
-
05 Nov 09
-
25 Oct 09
-
03 Oct 09
-
04 Aug 09
-
20 Jul 09
-
17 Jul 09
-
29 Jun 09
-
02 Jun 09
tompasley"The Apache server’s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user’s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the ‘dirt
howto apache web tutorial webdev programming url php mod_rewrite htaccess
-
28 Apr 09
-
17 Mar 09
-
09 Mar 09
-
24 Feb 09
-
11 Feb 09
-
05 Feb 09
Edmondo Antonacciredirects with apache's mod_rewrite
-
30 Jan 09
-
22 Jan 09
-
30 Dec 08
-
15 Dec 08
-
03 Dec 08
-
17 Nov 08
-
01 Nov 08
-
26 Oct 08
-
27 Sep 08
-
25 Sep 08
-
17 Sep 08
-
04 Sep 08
-
13 Aug 08
Antti LindströmA simple how-to for apache's URL rewrite module configuration
-
11 Jul 08
Michael Samuelsongreat refresher on mod_rewrite
-
23 Jun 08
-
12 Jun 08
-
09 Jun 08
-
26 May 08
-
09 May 08
-
02 May 08
-
27 Mar 08
-
25 Mar 08
Jason FowlerRewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1
-
21 Mar 08
-
20 Mar 08
-
19 Mar 08
-
14 Mar 08
-
27 Feb 08
-
14 Feb 08
-
12 Feb 08
-
11 Feb 08
-
06 Feb 08
-
31 Jan 08
-
22 Jan 08
-
28 Dec 07
-
17 Dec 07
-
02 Dec 07
-
27 Nov 07
-
22 Nov 07
-
01 Oct 07
-
20 Sep 07
-
03 Sep 07
-
28 Aug 07
-
01 Aug 07
Page Comments
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.