Checked At:01:32
2 Guests
0 Users
Online doing the past 15 Minutes!
brugbart.com - Edition/Last Updated: 13. October 2008
Posted The: 04/09/2008 - AT: 9:56
This Tutorial covers how to enable mod_rewrite to redirect, or rewrite requested URLs.
Simplifying your URLs can make it easier for your users to share your resources, as well as easier for some search engines to index your pages. It also solves the unencoded ampersand problem, which may trigger warnings in the validation of your markup.
The below example will redirect URLs from the Articles/NUMBER/, to the real URLs. This redirect happens on the server, and the user wont notice anything.
RewriteEngine on RewriteRule ^Articles/([0-9]+)/$ /?AID=$1
First i enabled the RewriteEngine by setting it to "on", next i typed in my rewrite rule, which is a simple regular expression.
Take the below.
^Articles/([0-9]+)/$ /?ARTICLE=$1
The ([0-9]*) part telles that the numbers 0-9 are allowed, and the following plus sign (+) tells that one or more is allowed, finally the parentheses is used to remember the content, this can later be accessed through the variable "$1", which will be used to pass the number on to the real URL. Basically this tells the server to rewrite the below root-relative URLs.
/Articles/NUMBER/
Into the following (root relative).
/?ARTICLE=$1
If you dont understand what i mean about root relative, then you should also read Absolute and Relative Paths.
One problem which is likely to be common for beginners, is broken URLs for their external stylesheets, and/or images. Mod_rewrite and relative paths, are known to cause problems, the solution is either to use absolute paths, or root relative paths. You should read Absolute and Relative Paths for more information.
Author: BlueBoden
Comments: [0]


Checked At:01:32
2 Guests
0 Users
Online doing the past 15 Minutes!
This page was created in 0.0953409671783 seconds
Welcome Guest