Forum Moderators: coopster
Now I am trying to get rid of the URL section that reads:
"index.php?"
using:
<?
ob_start('post_process');
function post_process($buffer) {
return preg_replace("'index.php/?([^\"\']+)'e", "'index.php'.implode('-', preg_split('/&¦=/', '\\1')).'.html'", $buffer);
}
?>
But I cannot figure after many trials how to deal with the final part.
and the new one:
[localhost...]
so the gain is only the addition of " .html "
and the .htaccess is:
RewriteEngine on
RewriteRule (index.php)-([^-]+)-([^-]+)\.html$ $1.html?$2=$3 [N,QSA]
RewriteRule index\.html index.php
Now I am totally baffled
I figured that I had to modif my Apache2 setup to turn mode_rewrite on
And now the results that I copied (above) are produced by the .htaccess REGARDLESS of the OB script
Why: I commented it out (The OB script) and get the same result with or without OB script
So now it is the reversed position the .htaccess works but the OB is useless (as is)
By the way I did borrow it from AndreaF in the bag of trick
I used OB because the added OB load on the server in my case is minimum
Thank you
So basically you have some existing pages which are already developed and you want to convert any URI prior to pushing it out to the browser? Then, in order for anybody to click and use that particular link you are using mod_rewrite.
I see two errors in your preg_replace function. The first question mark (?) needs to be escaped, you have your slash the wrong way. The second is that you are not stripping off the '.php' extension in your replacement value.
return preg_replace("'index.php\?([^\"\']+)'e",
"'index-'.implode('-', preg_split('/&¦=/', '\\1')).'.html'",
$buffer); Now I got a clean URL:
[localhost...]
but it results in a 404
is is due to the .htaccess?
Thank you
Henry