Page 1 of 1

Making internal links output look like clean url's

Posted: Wed Jul 23, 2008 10:48 pm
by jwrigh26
Okay, This is my first post and basically I've searched for a couple of days now trying to solve this problem so I thought I would finally post my own topic.

Simply Is it even possible and if so How can one make internal links of a page that are dynamic produce output that is a clean url.

I've done mod_rewrite and am able to type in a clean url but as far as clicking on links and what is being viewed in the browser address bar, it's still dynamic ugly looking urls.

The website I'm working on is http://www.aceokayama.com

if you type in something like http://www.aceokayama.com/about.html it goes to my site which is really
http://www.aceokayama.com/index.php?theXML=about.xml

I'm using a main index.php page to channel a bunch of different html and php pages through simple xml. It works and is cool (I think) but I want clean url's.

Can anyone help?

Code that might be useful is

first the index.php

Code: Select all

<?php
 
 
//Xace
//XML-Based Simple CMS system
//ACE English Website
// NOTE:  Requires simpleXML extensions in PHP 5.0!
 
//get an XML file or load a default
if (isset($_REQUEST["theXML"]) && $_REQUEST["theXML"] != "") { 
$theXML = $_REQUEST["theXML"];
} else {
$theXML = "ace.xml";
} 
 
//Open up XML file 
@$xml = simplexml_load_file($theXML);
 
if ( !$xml){
  print ("there was a problem opening the XML");
 
} else {
 
$xml = simplexml_load_file($theXML);
 
/*Start the head of the html*/  
    include ($xml->top);
    include($xml->css);
    echo"</head>\n";
/*Start the body of the html*/
    echo"<body>\n";
    include ($xml->wrapper);
    echo"<div id=\"header\">\n";
    include ($xml->navbar);
    echo"</div>";
    echo"<div id=\"sidebar\">\n";
    @include ($xml->sideNav);
    echo"</div>";
    echo"<div id=\"secondary\">\n";
    @include ($xml->secondary);
    echo"</div>";
    echo"<div id=\"main\">";
    include ($xml->main);
    echo"</div>";
    echo"<div id=\"footer\">\n";
    include ($xml->footer);
    echo"</div>\n";
    echo"</div>\n";
    include ($xml->bottom);
/*end of the html*/
}
 
?>
 
 
and second like for instance if $xml pulled up about_navbar.html it looks like this

Code: Select all

 
 
<div id="logo"><img src="Web/catlogo.png" width="200" height="120"/></div>
<div id="banner"><img src="Web/bannerAce.gif" width="820" height="100"/></div>
  <ul>
    <li><a href="index.php?theXML=ace.xml">Home</a></li>
    <li id="current"><a href="index.php?theXML=about.xml">About Us</a></li>
    <li><a href="index.php?theXML=school.xml">Schools</a></li>
    <li><a href="index.php?theXML=recruitment.xml">Recruitment</a></li>
    <li><a href="index.php?theXML=contact.xml">Contact</a></li>
  </ul>
 
All pages come from an .xml page like this

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<cpage>
    <top>html_pages/about_top.html</top>
    <css>html_pages/style.html</css>
    <wrapper>html_pages/wrapper.html</wrapper>
    <navbar>html_pages/about_navbar.html</navbar>
    <sideNav>html_pages/about_sideNav.html</sideNav>
    <secondary>html_pages/about_secondary.html</secondary>
    <main>html_pages/about_main.html</main>
    <footer>html_pages/footer.html</footer>
    <bottom>html_pages/bottom.html</bottom>
</cpage>
 
 
I'm using php 5.2.6 and apache 2.2.9 (Unix)

Any help would make my day
Thanks

Re: Making internal links output look like clean url's

Posted: Thu Jul 24, 2008 10:29 am
by malcolmboston
Clean URLS -> Mod Rewrite

Re: Making internal links output look like clean url's

Posted: Thu Jul 24, 2008 6:06 pm
by jwrigh26
That's a nice article about mod_rewrite. :)
and like I said up above, I've done mod_rewrite, but that's only for input. As far as output, the web browser still displays dynamic url's and when someone clicks on a link it still shows dynamic url's in the web browser address bar. :banghead:

Re: Making internal links output look like clean url's

Posted: Thu Jul 24, 2008 9:25 pm
by Eran
You need to put the clean form of the URL's inside your links for those to appear in the browser address line

Re: Making internal links output look like clean url's

Posted: Thu Jul 31, 2008 12:42 pm
by ghurtado
You can't rewrite what the browser sees. If a link in your HTML uses an A tag that goes to a "dirty" URL (like yours do), then the browser will always show the dirty URL. You can't rewrite that from the server, so you need to change the A tag to reflect the URL that you want the browser to see and show.

Simple really, when you think about it.

Re: Making internal links output look like clean url's

Posted: Fri Aug 01, 2008 10:10 am
by Mordred
It looks to me that you have a huge security hole, which may be severe (RFI) depending on the server config.

No way to test this at the moment (the code doesn't appear to be currently live on the site, which is good I suppose), but I think an attacker can give you a remote theXML, in which to put a valid remote $xml->top which you would then include.