bug in rewrite url

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Moozie
Posts: 164
Joined: Sat 8. Nov 2003, 00:21
Location: Netherlands

bug in rewrite url

Post 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?
User avatar
Oliver Georgi
Site Admin
Posts: 9900
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Moozie
Posts: 164
Joined: Sat 8. Nov 2003, 00:21
Location: Netherlands

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9900
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Yes it is - but time ;-)

The rewrite function has to be changed a bit.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Moozie
Posts: 164
Joined: Sat 8. Nov 2003, 00:21
Location: Netherlands

Post 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???
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post 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
Moozie
Posts: 164
Joined: Sat 8. Nov 2003, 00:21
Location: Netherlands

Post 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?
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9900
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Often problem is the rewrite of index.html -> this can cause errors when using WYSIWYG editor.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9900
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Habe kein Rewrite an - hat aber schonmal funktioniert (wenn ich mich recht entsinne).
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

Teste doch mal bitte durch wenn de Zeit hast,
Jan
Moozie
Posts: 164
Joined: Sat 8. Nov 2003, 00:21
Location: Netherlands

Post 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???
User avatar
Oliver Georgi
Site Admin
Posts: 9900
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post 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 ....
Post Reply