Forum Moderators: coopster

Message Too Old, No Replies

A question about an earlier post on PHP/Apache

RewriteRules

         

kwirl

5:53 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



I was tinkering around with using andreas' code for altering search string results, and have run into some problems. I know just enough about programming to realize that this is probably a basic oversight on my part, but I don't have enough grasp to actually see what I'm doing wrong. (Yet, I'll continue working at it, but I'm all about taking what help I can get to save time).

Anyway, let me show you my notes on the work I've done

//PHP
ob_start('post_process');
#
function post_process($buffer) {
return preg_replace("'preview.php\?([^\"\']+)'e", "'preview-'.implode('-', preg_split('/&¦=/', '\\1')).'.php'", $buffer); }

//.HTACCESS
RewriteEngine on
RewriteRule (preview.*)-([^-]+)-([^-]+)\.php$ $1.php?$2=$3 [N,QSA]
RewriteRule preview\.php preview.php

//Old Url /preview.php?item_id=00000231
//New Url /preview-item_id=00000231.php (HTTP 404)

//Put the ob_start code in the searchresults.php PHP script that generates the
//preview.php pages

The new URL is giving me a 404, so I'm looking at the code and wondering if I went wrong with my RewriteRule or with the post_process code.

Anyone remember this thread or recognize what I did wrong?

-Kwirl

kwirl

6:01 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



Ok, I've figured out that the problem is in my RewriteRule, so I'm tinkering with it now to see what I can do to fix it.

kwirl

6:05 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



Ok, maybe it isn't my rewrite rule. now i'm thinking that the post process might be funky in the preg_replace area

gah

kwirl

6:23 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



Ok, so maybe it doesn't like my item_id variable, guess i'll work around that

kwirl

6:25 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



Fixed the culprit

[quote]RewriteRule (preview.*)-([^-]+)=([^-]+)\.php$ $1.php?$2=$3 [N,QSA]quote]

jatar_k

6:28 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hehe, guess we were no help, don't do rewrites myself

glad you sorted it kwirl

kwirl

6:39 pm on Mar 25, 2005 (gmt 0)

10+ Year Member



thanks, I figure if I run into a problem, if i work it out on here then the steps I take might help other people who have the same problem. For people who care about their search engine placement, the modifications i just made (using you guys' help) will be something that you really need to do if your content is dynamically generated output.

I'm a newbie, but the more i contribute the less that title carries with me