HOW2 - create bot-friendly URL

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply

Is this HOW2 useful ?

year baby - great blowjob!
4
50%
such things are confusing me.
1
13%
fuk yu
3
38%
 
Total votes: 8

Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

HOW2 - create bot-friendly URL

Post by Jan212 »

Hello everbody,
this is no bugfix, my solution is hardcoded but is working as well...
The rewrite function isn't working with the alias function at the time, but this simple script will cause the same effect.
Enable the rewrite engine in includes/inc_conf/config.inc.php...
This hack is only concepted for better indexing of the main categories, but with a little bit of work it can be used for the whole system...
Add In your .htacces

Code: Select all

RewriteEngine On
RewriteBase /phpwcms_1.1/ 
RewriteRule ^anfragen.html$ index.php?id=1
RewriteRule ^([a-z]*)\.html$ index.php?id=$1
RewriteRule ^(.*)\.html$ index.php?id=$1
Code expl.
Line1: to enable mod_rewrite -
check it in your phpinfo under -> apache if it is enabled, otherwise go to your apache/conf/httpd.conf an enable it.

Line 2: the base of the files that have to be rewritten -
example: in case of http://myhost.de/phpwcms_1.1/ the RewriteBase is /phpwcms_1.1/

Line3
^ = Beginning of the loop
anfragen.html = the name of the file which you want to create
$ = End of the loop
index.php?id=1 = the ID of the categorie/article you want to rename- if you want to rename an article fill in this index.php?id=1,1,0,0,1,0 for example

Line4&5
These rules must be set to create files like 1.12.1.0.1.1.html.
I will use it for the news etc.
Please make sure that your indication classes(zeichenklassen)are set correctly.

In includes/inc_front/front.func.inc.php
replace your code with this...

Code: Select all

//Rewrite functions

function url_search($query)   
{ 
   if(strpos($query, "id")) $noid = substr($query, "4");
   else $noid = substr($query, "1");
   $file = str_replace(",", ".", $noid).".html"; //further use 
   //$file = $noid.".html"; 
   $link = "<a href=\"".$file."\""; 
   return($link); 
  //unset($link); 
}
You can also use [ID alias]string[/ID], the url will be transfered correct into ya browser, but the content is only shown if you define the rewrite rule in ya .htaccess...

That's all - best regards

A yockl from the deepest backwood of germany
Last edited by Jan212 on Tue 2. Mar 2004, 23:26, edited 2 times in total.
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
ionrock
Posts: 279
Joined: Fri 20. Feb 2004, 17:04

Post by ionrock »

I like the tutorial but I think there is a problem. I tried the .htaccess file and changing the url rewrite but in my case I use aliases for my main menu links. For example I had links to index.php?downloads and index.php?links. This is different from the articles because articles are formed by having index.php?id=1,0,0,0,4 where there is an id varaible passed. This shouldn't be a problem with a little regex in the .htaccess but it is still an issue it seems. I could be missing somethings though so please explain or send a link to more expanation of how we can deal with this issue. Thanks for the tutorial, I had just been working on mod_rewrite so it was a big help :)
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

Hello
You can also work with an alias, the codefix in front.function.inc.php enable this... The internal rewrite function is making anschrift.html from index.php?anschrift.
Best Regards
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

:arrow: ATTENTION
--------------------------------------------------------------
THERE IS A BETTER SOLUTION BY PIXELPETER
HERE
--------------------------------------------------------------
THANKS TO HIM, AWESOME

BEST REGARDS
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
Post Reply