Jump to content


This topic is now archived and is closed to further replies.


Exploding URLs messes up local links

Recommended Posts

Hi, I am writing a content management system and tried implementing mod_rewrite with it. Then I tried exploding the URL to get the same effect. Here is the code I used to do this:
$path_info = $_SERVER["PATH_INFO"];
            $path_info = explode("/", $path_info);
            $i = 0;
            foreach($path_info as $path_part){
                if($path_part != ""){
                    if($i == 0){
                        $pg = $path_part;
                    }elseif($i == 1){
                        $page_input = $path_part;
                        $page_input .= "," . $path_part;

Both mod_rewrite and exploding URLs causes the same problem. Things can't be linked locally. For example, if my the URL is [a href=\"http://somesite.com/araknid/index.php\" target=\"_blank\"]http://somesite.com/araknid/index.php[/a], I can say:
[code]<img src='templates/logo.png'>[/code] and it would world properly. But if the url was [a href=\"http://somesite.com/araknid/index.php/forum/t,12\" target=\"_blank\"]http://somesite.com/araknid/index.php/forum/t,12[/a] it doesn't work because it tries to load
[a href=\"http://somesite.com/araknid/index.php/forum/t,12/templates/logo.png\" target=\"_blank\"]http://somesite.com/araknid/index.php/foru...plates/logo.png[/a] , instead of [a href=\"http://somesite.com/ararak/index.php/templates/logo.png\" target=\"_blank\"]http://somesite.com/ararak/index.php/templates/logo.png[/a].

How can I fix this?

Thanks in advance.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.