-1

i have a site abc.com in php and now made anothers site abcd.com on rails, i wish to redirect all requests that go to the php site to redirect to abcd.com... example: abc.com/page3 -> abcd.com/page3 abc.com/non_existing_link ->abcd.com

this php site is just hard coded, not using any framework and i wish to write script in index.php which would accept ny link towards abc.com and then check the extension and redirect it accordingly to the corresponding links on abcd.com... i was suggested to write a controller from a collegue and i am not familiar with mvc functionalities nor th controllers class and stuff...

tereško
  • 58,060
  • 25
  • 98
  • 150

2 Answers2

0

If your webserver runs apache, I would recommend placing a .htaccess-file in the root of your original server as in the following answer: .htaccess redirect all pages to new domain. If you would like to keep the names the same (redirect to exactly the same name on your new domain), use the following lines:

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA]

This method works with very limited amount of work/coding :-)

Community
  • 1
  • 1
DaveG
  • 741
  • 6
  • 16
0

I believe you there are several ways to achieve so:

  1. Using php redirect in all php pages.

How to make a redirect in PHP?

  1. Modifying .htaccess file in your directory

http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F

  1. If you have a cpanel of other controler system from hosting provider then do it directly there.
Community
  • 1
  • 1
Adler Hsieh
  • 477
  • 3
  • 10
  • i dont wish to prepend a redirection code on each page of the site... i have around 40-100 individual php pages and i wish to just check the url etension and get its corresponding value from the xml file json file with oldlink => new link records base i have and redirect.. just wanna route using single script with cases – Bhavan Kuchibhotla Oct 20 '14 at 08:24
  • i used the 301 redirect technique in htaccess file... now when i open abc.com/team.php it redirects to abcd.com/abc.com/team.php , but all i want to do is check whats the subdirectory in the url after abc.com and get its corresponding redirection from the xml records i have and redict the page to that url.... – Bhavan Kuchibhotla Oct 20 '14 at 08:48