JK's Domain

Where My Experience, Thoughts and You Meets!

Forward A Subdomain

PROBLEM : I have a college website named “www.collegewebsite.com”, Now we want to create a sub-domain for placement cell at our college. College Authorities created a sub-domain named ‘placements’ which creates a folder ‘placements’, inside the root folder. now when i enter “placements.collegewebsite.com”, it automatically redirects to “www.collegewebsite.com/placements”

what I had done is added a file named “.htaccess”  from which we can give guidelines to apache server!

I added these lines into it

 

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^collegewebsite.com [NC]
RewriteRule ^(.*)$ http://www.collegewebsite.com/$1 [L,R=302]
RedirectMatch 302 ^placements/(.*)$ http://placements.collegewebsite.com/$1

 

What I had done is that, i told Apache server that, if a request comes for a site collegewebsite.com/placement, send the request into page http://placements.collegewebsite.com/ such that it hides the name ‘placements/’ from URI.

302 Redirect ~ TEMPORARILY REDIRECTED

301 Redirect ~ PERMANANTLY REDIRECTED

%d bloggers like this: