| |
| |
|
|
|
|
| |
|
| |
|
| :: |
| Author |
Message |
iguanairs
Joined: 16 Jul 2007 Posts: 2 Location: Massachusetts
|
Posted: Mon Jul 16, 2007 2:19 am Post subject: Special Rewrite Conditions |
|
|
Howdy all!
Ordinarily I am pretty savvy when it comes to the rewrite rules. I have hit a stump though.
How would I go about using this script to call the rewritten urls? I am getting an error at line 70 because the file it is seeking, the rewritten one, doesn't physically exist.
This is the file:
| Code: | <?php
include('multiconfig.php');
include('config.php');
$file = $_SERVER['REQUEST_URI'];
if($script_path)
{
$slash = '/';
}
$replace = $slash.$script_path.'/'.MFORUM.'/';
if($file == $slash.$script_path.'/'.MFORUM)
{
header('Location: '.$replace);
exit;
}
if(ereg('^'.$replace.'admin', $file) && !ereg('login\.php', $file))
{
chdir('admin');
$admin = 'yes';
$file = ereg_replace('^'.$replace.'admin/', '', $file);
}
if($admin != 'yes')
{
$file = ereg_replace('^'.$replace, '', $file);
}
if(!$file)
{
include('index.php');
exit;
}
$file = explode('?', $file);
$file = $file[0];
if(ereg('\.\.', $file))
{
die('<b><center>Invalid file!</center></b>');
}
$extension = explode('.', $file);
$count = count($extension);
$count--;
$extension = $extension[$count];
if(!function_exists('mime_content_type'))
{
function mime_content_type($file)
{
$extension = explode('.', $file);
$count = count($extension);
$count--;
$extension = $extension[$count];
$file = file('mime.dat');
for($i = 0; $i < count($file); $i++)
{
$line = $file[$i];
$line = explode(':', $line);
if($line[1] == $extension)
{
return $line[0];
}
}
}
}
if($extension == 'php')
{
include($file);
}
else
{
$mime = mime_content_type($file);
header('Content-type: '.$mime);
print file_get_contents($file);
}
?> |
Line 70 is the last line that reads: print file_get_contents($file);
The error is stating that the get contents file doesn't exist because it is attempting to retrieve the prewritten url. I need for that to see the original url, and then rewrite the url on the fly I guess.
Anyone have ideas as to how I could get this to work in unison with the rewrite rules?
Until I can get this corrected, I had to remove the modification. |
|
|
| Back to top |
|
 |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3477
|
|
| Back to top |
|
 |
iguanairs
Joined: 16 Jul 2007 Posts: 2 Location: Massachusetts
|
Posted: Wed Jul 18, 2007 12:51 pm Post subject: Re: Special Rewrite Conditions |
|
|
| SeO wrote: | Is this one really related to the mixed mod rewrite ?
Then, could you explain a bit more what are you trying to achieve exactly. |
Yes, this is related to the mixed mod rewrite.
I have a customized version of phpbb. It is designed and functions as a multi-forum platform running off a single installation of 2.0.22 (or whatever version I decide to use.)
In order for the application to work successfully, it gets processed through the file I posted.
That file however is trying to locate a file NAMED the rewritten URL. As we both know, the rewritten url doesn't "physically" exist, so it returns an error that the file can't be found.
I am looking for a rule that would either tell this file to look for the original file, and then process the rewrite, or for it to see the original and be informed it has been rewritten. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14403
|
Posted: Thu Jul 19, 2007 10:59 am Post subject: Re: Special Rewrite Conditions |
|
|
You could use some regex to do the trick.
But it would be easier if you add a $_GET var to the rewriterules, in order to identify the targeted phpBB file in your script.
| Code: | | RewriteRule ^[a-z0-9_-]+-c([0-9]+)\.html$ index.php?c=$1 [QSA,L,NC] |
Could be modded to :
| Code: |
RewriteRule ^[a-z0-9_-]+-c([0-9]+)\.html$ index.php?c=$1&script=index [QSA,L,NC] |
You'd be able to deal with $_GET['script'], after the appropriates checks (using an array of possible input files for example), to tell what file to deal with.
Looks like the less intrusive solution to me, and the easier too
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |