A Quick Hack for the rewrite function working with alias too

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

The Code is working...

Code: Select all

  else 
   { 
      // this is for mypage.html 
      $noid = substr($query,1); 
      $file = str_replace(",", ".", $noid).".html"; //further use 
   } 
   $link = "<a href=\"".$file."\""; 
   return($link); 
} 
place this after your else in the function url_search($query) and the chars shouldn't get lost...
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.
------------------------------------------------
gent
Posts: 163
Joined: Tue 16. Dec 2003, 13:51
Location: Berlin

Post by gent »

if i change the front.func.inc.php from:

Code: Select all

//Rewrite functions
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);
}
to:

Code: Select all

function url_search($query)
{
   if ( subStr($query,0,4) == "?id=") {
       $noid = substr($query, 4);
       $file = str_replace(",", ".", $noid).".html";
     } 
else 
    { 
       // this is for mypage.html 
       $noid = substr($query,1); 
       $file = str_replace(",", ".", $noid).".html"; //further use 
    } 
    $link = "<a href=\"".$file."\""; 
    return($link); 
 } 
then i get this error:

Code: Select all

Parse error: parse error in /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php on line 1204

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php:1204) in /usr/local/www/data.default/comodin/include/inc_front/content.func.inc.php on line 25

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php:1204) in /usr/local/www/data.default/comodin/include/inc_front/content.func.inc.php on line 26

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php:1204) in /usr/local/www/data.default/comodin/include/inc_front/content.func.inc.php on line 27

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php:1204) in /usr/local/www/data.default/comodin/include/inc_front/content.func.inc.php on line 28

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data.default/comodin/include/inc_front/front.func.inc.php:1204) in /usr/local/www/data.default/comodin/include/inc_front/content.func.inc.php on line 29

Fatal error: Call to undefined function: url_search() in /usr/local/www/data.default/comodin/index.php(71) : regexp code on line 1
and my .htaccess looks like this:

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off

RewriteEngine on 
RewriteBase /comodin 

# This will rewrite 0.0.0.0.0.html => index.php?id=0.0.0.0.0 
RewriteRule ^([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.html$ /comodin/index.php?id=$1.$2.$3.$4.$5.$6 

# This will rewrite mypage.html => index.php?mypage 
RewriteRule ^(.*)\.html$ /comodin/index.php?$1 
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

copy and paste the code from here plz - otherwise we'll getting trouble...

http://www.phpwcms.de/forum/viewtopic.p ... 9&start=15

Plz reply if it isn't working.
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.
------------------------------------------------
gent
Posts: 163
Joined: Tue 16. Dec 2003, 13:51
Location: Berlin

Post by gent »

ok, sorry .. i found the error.

it was about copy/pasting the code from the browser to my editor.
i guess there was wrong linebreaks. by rebreaking all lines in my editor the code is now working.

and [ID contact]click here[/ID] is linking cerrectly to */contact.html

liebe grüsse an Jan212 .. danke für deine geduld :)
ionrock
Posts: 279
Joined: Fri 20. Feb 2004, 17:04

Post by ionrock »

sweet... I am glad someone found an answer to that. I really needed it working
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

no problem - kein problem danke für die grüße...

ja unix und windows zeilenumbrüche sind ein unterschied, besonders in der .htaccess beachten beim WAMP 2 LAMP Export, das ist mir auch schon zum verhängniss geworden...

For everyone who has a 404 or on internal server error while tryin to use the rewrite func.
set up
+FollowSymLinks and
AllowOverride All
in your apache config...

PACE...
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.
------------------------------------------------
argos
Posts: 135
Joined: Mon 15. Mar 2004, 20:02

Post by argos »

Works like a charm! Thank you.
Regards,
Jurgen Nijhuis
http://www.argosmedia.nl
brans

Post by brans »

I think the only problem can be the settings that are mentioned above..

=> "If you have an 404 ..."

because the settings are all right, alle the links are being created correctly but I always get a 404 Error. :-(

But how can I find out if these settings are set correctly or not if I don't have root acces nor shell access ? Do I have to email my provider ?

And does this hack work with RC2 or not ?
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

hi,
please use the newest version
http://sourceforge.net/projects/phpwcms
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.
------------------------------------------------
brans

Post by brans »

of course I got that version! But on one of my projects there is still running RC2 and if not absolutely necessary I don't want to update, because RC2 is absolutely sufficient.
Chucky
Posts: 13
Joined: Wed 23. Jun 2004, 17:08

Post by Chucky »

geht das auch in deutsch ? :-) versteh ja kein einziges wort :P
Nate
Posts: 42
Joined: Sun 11. Apr 2004, 18:26

Post by Nate »

How can I configure RewriteEngine in .htaccess to not rewrite specific directories (I have other scripts running that I don't want their url's rewritten)?
To fathom hell or soar angelic...
leone
Posts: 21
Joined: Tue 19. Oct 2004, 11:30
Location: Switzerland

Post by leone »

Nice mod and after compiling the apache with the rewrite mod I got it working finally.

I have however had to change the function (url_search)

The line containing this

Code: Select all

$link = "<a href=\"".$file."\""; 
to:

Code: Select all

$link = " href=\"".$file."\""; 
As I was getting menus containing "<a<a href ..." in the Sourcecode for the clickable links. So some menus did not even appear as clickable, {NAV_ROW} menus would not show clickable links. Using the second version then solved that problem.

Btw, my pages have the extension .phtml. I have not found a way for them to use the .html extension. So also had to adopt the entries in the .htaccess accordingly.

Any ideas?

regards,

leone
Nate
Posts: 42
Joined: Sun 11. Apr 2004, 18:26

Post by Nate »

Actually, I should rephrase my question:

Do subdirectories inherit the rewrite rules of the parent directory?
To fathom hell or soar angelic...
Post Reply