SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to rewrite and redirect

    I want rewrite this:

    http://www.mydomain.com/myoldpage.php?myvar=my query string

    to

    http://www.mydomain.com/my-new-page.php

    I tried several thing but no success.

    What I want to achieve is: if a use open new page it should show content of old page but if opens old page it should redirect to new but show old page content.

    Thanks!

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,656
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    aryan,

    Well, you've said a mouthful but no useful information (for creating a pattern from old to new).

    Let me first recommend a thorough reading of the mod_rewrite tutorial linked in my signature (including the coding examples).

    THEN I suggest that you consider your site redesign so that the old pages can be redirected via some pattern matching to the new pages. If you do that properly, I'd suggest that my_query_string is the filename of the new script, my-new-page.php so that you can actually use mod_rewrite to redirect to the value of my_query_string [R=301] THEN on to my_query_string.php without displaying the .php file extension. Some call it "pretty URIs," I call it extensionless URIs. If my_query_string.php actually gets redirected to a file handler to access the database (e.g., for the title field rather than the id field), that becomes rather trivial, too (e.g., http://wilderness-wally.com).

    Okay, perhaps I've raced too far ahead of you. Look FIRST and FOREMOST to creating a pattern between my_query_string and my_new_page as the babystep before running as I was describing.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •