Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: htaccess redirects for URLs with arguments

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm pretty sure you could have it in a separate file, that file would have to be included on doc.php as the first thing. You can do virtually anything you want within the if section though, like call up data and so forth, as long as it's not output to the page as text. Once you write to the page, you can no longer redirect.

    Yep, include works fine. Here's my redirect.inc page:

    PHP Code:
    <?php
    if(isset($_GET['title']) && $_GET['title'] === 'john'){
        
    header("HTTP/1.1 301 Moved Permanently"); 
        
    header('Location: ' $_SERVER['PHP_SELF'] . '?renamed=john&id=3340');
        exit;
    }
    ?>
    And now, on doc.php all I need is:

    PHP Code:
    <?php
    include 'redirect.inc';
    ?>
    Last edited by jscheuer1; 12-08-2016 at 07:22 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 1
    Last Post: 01-02-2010, 10:59 PM
  2. .htaccess help to rewrite URLs
    By Beverleyh in forum Looking for such a script or service
    Replies: 3
    Last Post: 06-11-2009, 12:18 PM
  3. Resolved Tracking dynamic .HTACCESS redirects?
    By Spinethetic in forum PHP
    Replies: 1
    Last Post: 05-02-2009, 03:22 PM
  4. Resolved Help with passing arguments with AJAX
    By Schmoopy in forum JavaScript
    Replies: 2
    Last Post: 03-09-2009, 07:10 PM
  5. Using htaccess for permanent redirects
    By wkenny in forum Other
    Replies: 0
    Last Post: 01-29-2006, 11:34 PM

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
  •