Posts

Showing posts with the label redirect

.htaccess redirect FROM subfolder to domain name

.htaccess redirect FROM subfolder to domain name I had website content in a subfolder (http://mydomain.com/subfolder/index.php), now I copied everything over to the root folder (http://mydomain.com/index.php). I would like to redirect all the visitors that have bookmarked the old page to the new content (at least to the new index.php) using .htaccess. Is this correct: RewriteEngine on RewriteRule /subfolder/^(.*)$ http://mydomain.com [R=301,L] ? And where would I place the .htaccess file, in the subfolder or the root folder? 3 Answers 3 Placing the following .htaccess in / (where your index.php is located) should do the trick: .htaccess / RewriteEngine on RewriteRule ^subfolder/(.*)$ /$1 [R=301,L] Or you could place the following .htaccess in /subfolder : .htaccess /subfolder RewriteEngine On RewriteRule ^(.*)$ /$1 [R=301,L] Note that the () around .* and the $1 redirects /subfolder/someFile.p...

Need a way to temporarily redirect STDOUT

Need a way to temporarily redirect STDOUT I know how to redirect output in Linux. Thing is, I have alot of output in my bash script and I don't want to type something like echo $foo >> bar over and over again. I would much rather do something like: hey, bash, for the time being put all your STDOUT in "bar" echo $foo . . OK, bash, you can go back to regular STDOUT now I tried opening FD 1 as a file: exec 1>bar but couldn't get STDOUT back to normal when I was done. Closing the file exec 1>&- gave me errors that I couldn't get around. Any way to do this? Thanks! 3 Answers 3 You have to first save stdout (by linking it on fd #4 for instance) exec 4<&1 Redirect stdout exec 1>bar And restore saved stdout exec 1<&4 OK, learned something new about file descriptors here. Any references on what it means to 'save' ...