Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    301 Dynamic Redirect

    I want to redirect a dynamic URL. Using this overwrite. But I need some advice of changes since I've yet to do much in regex

    Code:
    redirect 301 ^folder/([^/.]*)/?/([_A-Za-z0-9-]+).html/?$ http://www.domain.com/newFolder/$1/$2.html
    or even if possible taken the actual domain and redierctly a quick URL change, all I want, is if its this "/folder/" make sure the url shows "/newFolder/"

    (main use is for SEO to know that the URL has just been moved to this new folder, but I dont want to change the $1 and $2 variables of data, the URL must be as identical to the user, just a folder switch. I've seen this on websites, where they instantly make the URL change among countries ..etc

    Pretty much the same as a statement that would print out as if (dir=folder) dir = newFolder, but printing as regex is concerned, I dont have much of an idea how to put

    (its easy to do something like this Redirect 301 /dir/ http://www.example.com/newdir/ but I want to still keep the entire URL intact)

    Thank You.
    Last edited by sitNsmile; 11-30-2010 at 04:46 PM.

  • #2
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Let the force be with you!

  • #3
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    PHP Code:
    if (ACTION=='GLINK' && PAGE=='linkout')
    {
        
    header("HTTP/1.1 301 Moved Permanently");
        
    header("Location: ".BASEURL.ZONE_PREHOSTED."/".$varId."/".$varName.".html");
        exit();

    Last edited by sitNsmile; 12-02-2010 at 03:14 PM.

  • #4
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Okay, I decided to do some more work into this, and I figured it out, here's the dynamic redirect.

    Code:
    RewriteRule ^oldDir/([^/.]*)/?/([_A-Za-z0-9-]+)\.html$ http://www.domain.com/newDir/$1/$2.html [R=301]
    Last edited by sitNsmile; 12-02-2010 at 03:09 PM.

  • #5
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Code:
    # Do a proper 301 permanent redirect for Google's sake
    RewriteRule /oldfolder/(.*) /newfolder/$1 [L,R=301]
    
    # Now do your normal internal redirect with your variables and such
    Or something like that.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #6
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Lamped View Post
    Code:
    # Do a proper 301 permanent redirect for Google's sake
    RewriteRule /oldfolder/(.*) /newfolder/$1 [L,R=301]
    
    # Now do your normal internal redirect with your variables and such
    Or something like that.
    I originally was trying to accomplish this, I was unable to figure the regex for "(.*)" .

    however for the configuration, I'd advise using the "^"

    Thank You for that.
    Last edited by sitNsmile; 12-02-2010 at 03:12 PM.

  • #7
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Quote Originally Posted by sitNsmile View Post
    however for the configuration, I'd advise using the "^".
    Oops, wasn't thinking. Would it surprise you to know I tend to edit my .htaccess files twice?
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

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