Jump to content
Sign in to follow this  
zeeba42

str_replace so I can redirect with htaccess

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 redirectRedirect 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;

Share this post


Link to post
Share on other sites

The browser still gets the index.php page, when you request a directory name instead of a filename (e.g. www.google.com/ instead of www.google.com/index.pl) then the web server looks for an index page in that directory and uses that, so it's running the index.php. He just has it set up to look for the querystring variable and include another PHP file based on that value. There's an answer to your other question here: http://www.simonecarletti.com/blog/2009/01/apache-query-string-redirects/

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...