Jump to content

str_replace help


Recommended Posts

I have remade my company webpage using very little php mostly because I don't know it however the last web designer seemed to love it and now all the links that are out in the big www start with "?p=" and I can't do a 301 redirect on those pages. how do I rewrite those links as they are coming in to change ?p=page to page/php so I can properly redirect them in my htaccess file.


Redirect 301 /?p=oldpage http://www.mypage.com/newpage.php/ won't redirect

Redirect 301 /oldpage.php http://www.mypage.com/newpage.php/ will redirect



I found this in his index.php file and I think thats what he used to change the .php to ?p=


$page = (isset($_GET['p']) ? $_GET['p'] : $homePage);
$page = basename($page);
$page = str_replace(".php","",$page);

if(!file_exists($page . '.php')){
 $page = $errorPage;


Link to comment
Share on other sites

  • 4 weeks later...

Yes - that section is what you think it is.  So - if you have used "some" php, why not continue to use this part as well?  His use of "?p=xxx" is not just the use of PHP, it is a standard url with a GET parm.


Or are you looking for some php code to resolve the existing urls?


Or are you done with this problem?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.