Is it possible to redirect a "?p="

Discussion in 'Web Design and Development' started by JRomero, Mar 25, 2010.

  1. JRomero macrumors regular

    JRomero

    Joined:
    Jun 29, 2006
    #1
    Hello all,

    A few years back, I had a Wordpress site that used the ?p= suffix to the url to display posts. Currently, I no longer have the Wordpress site, but one of my posts still gets lots of traffic. Is there I could point ?p=40 to some other page or directory?

    Thanks for your help,
    Jason
     
  2. SilentPanda Moderator emeritus

    SilentPanda

    Joined:
    Oct 8, 2002
    Location:
    The Bamboo Forest
    #2
    You could make a simple "p.php" page and have it redirect to a static page if 40 was there in the URL, otherwise redirect to your new homepage.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    You can use a .htaccess file redirect.
    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^p=40$
    RewriteRule .* /newpage.html [L]
     
  4. JRomero thread starter macrumors regular

    JRomero

    Joined:
    Jun 29, 2006
    #4
    Thanks to the both of you for your help!

    SilentPanda, I tried making a p.php page, but it didn't do anything, unfortunately. :(

    angelwatt, I was hoping somebody new how to write a proper .htaccess RewriteRule! :D Unfortunately, when I use this, the ?p=40 leads to 500 Internal Server Error. Could there be an alternate RewriteRule I could try?
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    Can you show what you put in your .htaccess file? Syntax is very key. The 500 error generally means it doesn't understand something in the .htaccess file. Also, do you know the web server version?
     
  6. JRomero thread starter macrumors regular

    JRomero

    Joined:
    Jun 29, 2006
    #6
    This is what is in my .htaccess:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^p=40$
    RewriteRule .* /iphone.php [L]

    I have a Linux server with Apache version 2.0.63
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #7
    That looks good. I found this page where the guy is wanting to do the same thing as you. It looks like the main differences are that he's redirecting to another domain and on the rule line he's using ^$ rather than .*, which could make a difference. He's also using a redirect code (the 301) at the end, which is a good idea too so the search engines will update their index when they hit it.

    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^p=40$
    RewriteRule ^$ /iphone.php [R=301,L]
     
  8. JRomero thread starter macrumors regular

    JRomero

    Joined:
    Jun 29, 2006
    #8
    angelwatt! That did the trick! Thank you very much!!! :D
     

Share This Page