index.php?id=8,0,0,1,0,0 to 8.0.0.1.0.0.html HOWTO
Posted: Wed 19. Nov 2003, 23:12
hi all
i am new with phpwcms. donwloaded installed, expirienced some errors but found it cool. after thinking about searchengine compatibility i read some threads about and implemented a solution for it, thought probably someone would also be interested:
step 1:
open index.php in your root directory
add the following lines at the begin (directly after gnu licence) of your index.php
go to the bottom of index.php and enter the following lines after your </body>
</html>
step 2:
go to /include/ and create a new directory called 'inc_rewrite'
step 3:
create a new file called 'rewrite_url.php' and insert the following code:
don't forget to save your file!
step 4:
see what happened and reload your output page, you will now see the links in new format. if you click you will get an error message (404)
step 5:
go to your wcms root directory and create a new file called '.htaccess'. insert this code to the newly created file:
check if ../ is needed on your host! and again don't forget to save!
step 6:
see your pageoutput and browse through, your links should now be cleany set and if you click a page should be delivered (without warranty) it works for me
greetings marc
i am new with phpwcms. donwloaded installed, expirienced some errors but found it cool. after thinking about searchengine compatibility i read some threads about and implemented a solution for it, thought probably someone would also be interested:
step 1:
open index.php in your root directory
add the following lines at the begin (directly after gnu licence) of your index.php
Code: Select all
ob_start();
// set the error reporting level for this script
header ("Expires: Mon, 01 Jan 1990 01:00:00 GMT");
header ("Content-type: text/html");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
$_GET['id'] = str_replace(".",",",$_GET['id']);
</html>
Code: Select all
<?php
$wcms = ob_get_contents();
while(@ob_end_clean());
include_once("./include/inc_rewrite/rewrite_url.php");
echo $wcms;
?>
go to /include/ and create a new directory called 'inc_rewrite'
step 3:
create a new file called 'rewrite_url.php' and insert the following code:
Code: Select all
<?php
// this makes url from index.php?id=8,0,0,1,0,0 to 8,0,0,1,0,0.html
function url_search($query)
{
$noid = substr($query, 4);
$file = str_replace(",", ".", $noid).".html"; //further use
//$file = $noid.".html";
$link = "<a href=\"".$file."\"";
return($link);
//unset($link);
}
function js_url_search($query)
{
$noid = substr($query, 4);
$file = str_replace(",", ".", $noid).".html"; //further use
//$file = $noid.".html";
$link = "onClick=\"location.href='".$file."'";
return($link);
//unset($link);
}
// this regex's call the function
$allowed_chars_in_url = "[".implode("]|[",array("@",",","\.","+","&","-","_","=","*","#","\/","%","?"))."]";
$wcms = preg_replace("/(<a href=\"index.php?)(([a-z]|[A-Z]|[0-9]|".$allowed_chars_in_url.")*)(\")/e","url_search('\\2')",$wcms);
$wcms = preg_replace("/(onClick=\"location.href='index.php?)(([a-z]|[A-Z]|[0-9]|".$allowed_chars_in_url.")*)(\')/e","js_url_search('\\2')",$wcms);
?>
step 4:
see what happened and reload your output page, you will now see the links in new format. if you click you will get an error message (404)
step 5:
go to your wcms root directory and create a new file called '.htaccess'. insert this code to the newly created file:
Code: Select all
RewriteEngine on
RewriteRule ^(.*)\.html$ ../index.php?id=$1
RewriteRule ^index.html$ ../index.php
step 6:
see your pageoutput and browse through, your links should now be cleany set and if you click a page should be delivered (without warranty) it works for me
greetings marc