Redirecting a website using .htaccess

A few weeks ago, I started working for a new institution. I needed to move my website from the old institution's web server to the new one, that is from http://old.institution.edu/~jspronck/webs/ to http://new.institution.edu/~spronck/.

For simple cases, you can get away with Redirect 301.

If you need something a little more sophisticated, you can use Apache's URL rewriting engine, which can do some fancy stuff. This link was also useful.

In my case, I ended up adding the following three lines in the .htaccess file (the file should be located in the directory of the site that needs redirection; if there is none, just create one with a text editor. Remember that files starting with . will automatically be hidden).

RewriteEngine on
RewriteRule .*Photography/(.*) http://new.institution.edu/~spronck/Photography/$1 [R=301,L]
RewriteRule .* http://home.new.institution.edu/~spronck/Welcome.html [R=301,L]


The second line redirects all pages of the Photography directory into the same page of the photography directory of the new institution. The third line redirects any page of the directory where the .htaccess is saved to the Welcome.html page at the new institution. R=301 means that it is a permanent change and L is there to say that the URL will not be rewritten by future RewriteRule if the URL matches the rule.

Comments

  1. Roulette is an intriguing sport that's played all through the world. The large payoffs which are be} possible for small wagers stimulate the interest of the professional nicely as|in addition to} the novice player, playing 로스트아크 in} Roulette in Vegas. Be around fun folks and have cash in your pocket each evening as a mixologist, or claim your house within the ever-growing casino gaming trade in as little as three months. You can begin one of Crescent's top-quality packages with no money down.

    ReplyDelete

Post a Comment

Popular Posts