Jump to content

str_replace help


bwhite

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
https://forums.phpfreaks.com/topic/277764-str_replace-help/
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
https://forums.phpfreaks.com/topic/277764-str_replace-help/#findComment-1434243
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.