Page 1 of 3

bug in rewrite url

Posted: Tue 3. Feb 2004, 02:54
by Moozie
I have a page made in the admin called "Pagina 2" and
alias this category: Pagina_2

In the template I placed this tag in the right column box:

Code: Select all

[ID pagina_2]Go to page 2[/ID]
If I set the rewrite_url to 1, and look to the links in that right colums it tries to link to:

Code: Select all

http://www.mydomain.com/ina_2.html


where it has to be:

Code: Select all

http://www.mydomain.com/pagina_2.html


Is this a bug?

Posted: Thu 5. Feb 2004, 17:40
by Oliver Georgi
As I know the rewrite function has one big problem - can not handle alias. I haven't time to check the rewrite stuff - because it is not very handy at the moment becauseof some "not really" bugs.

Oliver

Posted: Sun 15. Feb 2004, 23:46
by Moozie
Will this be fixed then in the near future? It's a pitty that the site can't be spidered by engines.

I hope this issue will be somewhere in your todo-list

Posted: Mon 16. Feb 2004, 00:04
by Oliver Georgi
Yes it is - but time ;-)

The rewrite function has to be changed a bit.

Oliver

Posted: Mon 16. Feb 2004, 00:12
by Moozie
OK I searched on the forum and found out that if I change :

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off

RewriteEngine on 
RewriteRule ^(.*).html$ ../index.php?id=$1 
RewriteRule ^index.html$ ../index.php
into

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off

RewriteEngine on 
RewriteRule ^(.*).html$ ./index.php?id=$1 
RewriteRule ^index.html$ ./index.php
(NOTE: Difference is the double point ../)

With this change it works. But works only on button links (so the navigation buttons).

Only the links that I made in the right column like:

Code: Select all

[ID page_7]Click to go to page 7[/ID]
doesn't work. If I hoover ebove a link like that I see that the first 3 characters of the link are removed. So instead linkinf to "./page_7.html" it links to "e_7.html" --> NOT FOUND.

I think this could be another problem than the problem in the question that you answered so maybe you know how to fix this???

Posted: Mon 16. Feb 2004, 11:43
by Jan212
in includes/front.func.inc.php around 1084

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);
}
replace your rewrite function with this...(backup before!!!)

Regards, Jan

Posted: Mon 16. Feb 2004, 13:52
by Moozie
OK thanks that solves the problem. Now it's linking to page_7.html, but the link is going nowhere.

When rewrite is off the link shows:

Code: Select all

http://www.mydomain.com/phpwcms/index.php?page_7
This one works. If I click I see page 7.

When rewrite_url = on then I see the link like:

Code: Select all

http://www.mydomain.com/phpwcms/page_7.html
But if I click I see the HOME-PAGE. So the starting page.

Oliver mentioned once that it had something to do with alias. I mean: page_7 is an alias name set in the admin.

Maybe it has something to do with the .htaccess file. It was delivered with an underscore like: _.htaccess. I changed it into .htaccess and filled it with:

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off

RewriteEngine on 
RewriteRule ^(.*).html$ ./index.php?id=$1 
RewriteRule ^index.html$ ./index.php
Somewhere on the forum I read that it had to be ./index.php instead of ../index.php. That helped a bit. I did not get server errors anymore.

Did you get the link working? And how?

Posted: Tue 17. Feb 2004, 11:45
by Jan212
Couldn't get it working because of mod_rewrite. every times i try i got an error 404 couldn't find page... finally my mod_rewrite didn't ran so i decided to look in every mod_rewrite included file, but couldn't find the bug.
I think the bug is in your .htaccess
try this:

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off
RewriteEngine on
RewriteRule ^([a-z]*)\.html$ %{DOCUMENT_ROOT}/index.php?$1
RewriteRule ^(.*)\.html$ %{DOCUMENT_ROOT}/index.php?id=$1
RewriteRule ^index.html$ %{DOCUMENT_ROOT}/index.php
Please reply if this will work....
Regards, Jan

Posted: Tue 17. Feb 2004, 12:09
by Oliver Georgi
Often problem is the rewrite of index.html -> this can cause errors when using WYSIWYG editor.

Oliver

Posted: Tue 17. Feb 2004, 12:23
by Jan212
Hi Olli,
hast du nen WAMP am laufen, und funzt da das mod_rewrite

Code: Select all

<?php
if (!empty($check_mod_rewrite)) {
   $rewrite_result = 1;
} else {
   $rewrite_result = 0;
}

if ($rewrite_result == 1) {
     $result = "Mod_Rewrite is successfully installed!";
} else {
     $result = "Mod_Rewrite is either not installed or is not configured properly!";
}

echo $result;

?>

Meins nämlich nicht... Wenn ja kannste mir ja mal nen Link schicken oder auch jeder andere...
SUCHE WAMP
mit PHP 4+ Apache/sql vers. latte haupsache openSSL/mod_ssl , mod_perl mit und funzendes mod_rewrite am laufen...

Vorraussetzung das funzt, würde ich mal nen Tut schreiben zur rewrite function, falls das was bringt....

hightere Grüße, Jan

Posted: Tue 17. Feb 2004, 12:38
by Oliver Georgi
Habe kein Rewrite an - hat aber schonmal funktioniert (wenn ich mich recht entsinne).

Posted: Tue 17. Feb 2004, 13:06
by Jan212
Teste doch mal bitte durch wenn de Zeit hast,
Jan

Posted: Tue 17. Feb 2004, 15:33
by Moozie
Jan,

No this does not solve the problem (in fact extra errors appeared when I used your .htaccess). Remember that the only problem I experience with the rewrite_url is that I can not make links with the [id alias_name]-tag. But Oliver posted that that was a known bug. Although I do not quite understand what he means. I think it means that you can only work with the navigation-buttons and if you want to link to a page, you have to use [int http:\\www.mydomain.com/0.23.0.0.0.1.html]-tag.

Do I understand that correctly Oliver???

Posted: Tue 17. Feb 2004, 16:02
by Oliver Georgi
Problem is the "id" checking - alias does not have an "id". This has to be fixed in the frontend functions handling rewrite stuff.

But I have not enough time to check that again.

Oliver

Posted: Tue 17. Feb 2004, 16:08
by Jan212
i think it works with an alias, in my case the url is correct - for example index.php?kontakt will be kontakt.html ....