Login   Register  
PHP Classes
elePHPant
Icontem

HN URL Rewrite: Emulate request URL rewriting and redirection

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2004-09-19 (10 years ago) RSS 2.0 feedStarStarStarStar 61%Total: 8,052 All time: 197 This week: 1,386Down
Version License Categories  
hn_urlrewrite 1.0.0GNU Lesser General Publ...HTML, HTTP
Description Author  

This class can emulate a page request URL rewriting and redirection specified within the same PHP script.

It can a PHP script handle a request with an URI like this:

/home/name.php?p1=a&p2=b&xy=123

when it is requested a page with an URI like this:

/goto/home/name/xyz/NQw/NQi/RwSy=/index.html

or, optionally with strong encoding, to with an URI like this:

/goto/home/name/xyz/Sm9obZjhsz6s/amBzb29zdC5jb20=/MTIU2NzgY1g==/index.html

The request redirection emulation is done by rewriting some request variables that contain request paths, like SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, REQUEST_URI, PATH_TRANSLATED, and QUERY_STRING.

It can parse and change the output of the current page script to rewrite the URLs links (also in image maps) or images in the page with absolute URLs, relative URIs and URLs that contain scheme and host (http://www.somehost.com). Relative parent directory URIs (../) are also supported.

You can do the rewriting by using PHP buffering support.
Then the class optionally can compress the processed page output to serve the page in less time if the user browser supports compression.

Or you can rewrite a string with the string-rewrite method, if you cannot (or don't) want use the buffering support.

For detailed description see readme file.

Innovation Award  
PHP Programming Innovation award nominee
September 2004
Number 2


Prize: One downloadable copy of Roadsend PHP Compiler
There is the conviction between experience Web site developers that search engines index more pages of a site and do it faster if their page URLs are normalized.

There is not an absolute certainty about the accuracy of this conviction because the search engine companies do not confirm or deny it in public. Despite this, many site developers systematically normalize their pages URLs so their sites gain more visibility in the search engine result pages and they get more visits for free.

Normalization consists in making the pages be served under an URL without any query parameters that usually follow the question mark in the original URLs. The normalized URLs make the query parameters appear as if they are directory path names of site page virtual files.

http://www.somesite.com/browse.php?content=something

becomes for instance:

http://www.somesite.com/browse/content/something/

The most popular Web servers come with modules that rewrite the page URLs, so the scripts that generate the pages do not need to be changed to normalize the URLs. However, not every site can make use of Web server modules to rewrite URLs.

This class provides a PHP only solution for rewriting page URLs. Since it does not require a special Web server module, it makes possible for many more sites to also take advantage for URL rewriting benefits.

Manuel Lemos
Picture of Horst Nogajski
Name: Horst Nogajski <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 45
All time rank: 475 in Germany Germany
Week rank: 1130 Down56 in Germany Germany Down
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Files folder imagehn_urlrewrite_example (2 files, 1 directory)
Accessible without login Plain text file example0.php Example example
Accessible without login Plain text file goto Appl. this script handles the redirection
Accessible without login Plain text file hn_urlrewrite.class.php Class Classfile
Accessible without login Plain text file hn_urlrewrite_readme.txt Doc. readme
Accessible without login Plain text file htaccess_txt Data entry for htaccess file in servers root dir

  Files folder image Files  /  hn_urlrewrite_example  
File Role Description
Files folder imagesub1 (1 file)
  Plain text file example1.php Example example
  Plain text file example2.php Example example

  Files folder image Files  /  hn_urlrewrite_example  /  sub1  
File Role Description
  Plain text file example3.php Example example

 Version Control Unique User Downloads Download Rankings  
 0%Total:8,052All time:197
 This week:0This week:1,386Down
 User Ratings  
 
 All time
Utility:82%StarStarStarStarStar
Consistency:71%StarStarStarStar
Documentation:62%StarStarStarStar
Examples:73%StarStarStarStar
Tests:-
Videos:-
Overall:61%StarStarStarStar
Rank:741