...

View Full Version : 301 Dynamic Redirect



sitNsmile
11-30-2010, 05:37 PM
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


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.

sitNsmile
12-01-2010, 01:25 AM
Let the force be with you!

sitNsmile
12-02-2010, 02:29 PM
if (ACTION=='GLINK' && PAGE=='linkout')
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".BASEURL.ZONE_PREHOSTED."/".$varId."/".$varName.".html");
exit();
}

sitNsmile
12-02-2010, 02:45 PM
Okay, I decided to do some more work into this, and I figured it out, here's the dynamic redirect.



RewriteRule ^oldDir/([^/.]*)/?/([_A-Za-z0-9-]+)\.html$ http://www.domain.com/newDir/$1/$2.html [R=301]

Lamped
12-02-2010, 02:50 PM
# 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.

sitNsmile
12-02-2010, 04:09 PM
# 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.

Lamped
12-02-2010, 05:46 PM
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? ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum