Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
hitwalker
Sells PC To Pay For Divorce


Joined:
Posts: 5661

PostPosted: Sat May 28, 2005 9:52 am Reply with quote

Anyone can give an example of how the rewrite should look like if i wanted to use it for this link example..
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Sat May 28, 2005 11:50 am Reply with quote

I still use the original GT so I will respond with that. In header.php you would have
Code:
function replace_for_mod_rewrite(&$s) {

    $urlin = array("'(?<!/)modules.php\?name=Downloads'");
    $urlout = array("downloads.html");
    $s = @preg_replace($urlin, $urlout, $s);
    return $s;
}

Then the .htaccess would be
Code:
RewriteRule ^downloads.html downloads.html [L]


Last edited by Raven on Sat May 28, 2005 12:51 pm; edited 2 times in total 
View user's profile Send private message
hitwalker
PostPosted: Sat May 28, 2005 12:18 pm Reply with quote

ah okay,but where should the header part be put?
cause different positions turns site into blank..
 
Raven
PostPosted: Sat May 28, 2005 12:50 pm Reply with quote

I just noticed a typo in my other post - sorry.
Code:
$urlout = array("'"downloads.html"'");


should be

$urlout = array("downloads.html");

I have fixed it. Does that solve your problem or do you need the full GT code for your site?
 
hitwalker
PostPosted: Sat May 28, 2005 12:58 pm Reply with quote

well raven,weird thing is..
i took that "original"?..stuff from that gt next gen site...(version 2003 ?) and installed it by the letter..
but then i got on all modules ...you cannot access this directly common error...
was easy install but test site went dead...
and therefore unable to see if it all works....
 
Raven
PostPosted: Sat May 28, 2005 1:00 pm Reply with quote

I assumed that you were already using GT and could just modify your statements to accommodate those - sorry Smile

In header.php you probably have code similar to
Code:
if (eregi("header.php",$_SERVER['PHP_SELF'])) {

    Header("Location: index.php");
    die();
}

require_once("mainfile.php");

Modify it to read
Code:
if (eregi("header.php",$_SERVER['PHP_SELF'])) {

    Header("Location: index.php");
    die();
}

ob_start();
function replace_for_mod_rewrite(&$s) {
    $urlin = array("'(?<!/)modules.php\?name=Downloads'");
    $urlout = array("downloads.html");
    $s = @preg_replace($urlin, $urlout, $s);
    return $s;
}

require_once("mainfile.php");


Then in footer.php insert this code after function foot();
Code:
$contents = ob_get_contents(); // store buffer in $contents

ob_end_clean(); // delete output buffer and stop buffering
echo replace_for_mod_rewrite($contents); //display modified buffer to screen
 
hitwalker
PostPosted: Sat May 28, 2005 1:07 pm Reply with quote

So do i understand this correctly?
can a simple rewrite be used with nuke without installing a full GT ?
 
Raven
PostPosted: Sat May 28, 2005 1:11 pm Reply with quote

I gave you all the code you need to rewrite and GT that. You don't need anything else. What exactly are you wanting to do?
 
hitwalker
PostPosted: Sat May 28, 2005 1:20 pm Reply with quote

well i was reading some stuff on rewrite yesterday and got caught by the idea and started trying...
but i got stuck on the usual stuff people use and that didnt worked...
and what i want?
I just wanna see how it goes if i just change one url...like the one posted of the downloads,so to let it end as .html
 
Raven
PostPosted: Sat May 28, 2005 1:33 pm Reply with quote

But unless you have code in nuke to translate that back to what nuke uses it does no good. See what I mean? You can have
Code:
RewriteRule ^modules.php?name=Whatever Whatever.html [L]
and that will rewrite the url but nuke won't know what to do with it unless you have a file called Whatever.html.
 
hitwalker
PostPosted: Sat May 28, 2005 1:40 pm Reply with quote

Yes i see,so the piece you posted above would be enough?
 
hitwalker
PostPosted: Sat May 28, 2005 1:58 pm Reply with quote

ok...used the posted part and that works..
so now the tricky part...
using it for more mods does it simply means..duplicate the...

Code:


$urlin = array("'(?<!/)modules.php\?name=Downloads'");
$urlout = array("downloads.html");


?
 
Raven
PostPosted: Sat May 28, 2005 11:48 pm Reply with quote

Yes, but there's much, much more if you start passing data through the url Laughing - Better read up on mod_rewrite Wink
 
hitwalker
PostPosted: Sun May 29, 2005 10:18 am Reply with quote

yeah i know,thanks raven....Smile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©