0

I'm trying to redirect a router to a certain PHP page stored on what I think is CentOS on my AMI (Amazon Machine Image). I've done a bit of research and have found that other people were having the same problem: I've looked here, and here and what I got was that I need an elastic IP for the instance that has the page I want to redirect to, but I already have that.

I've tried ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page, as well as (just the IP) xx.xxx.xxx.xxx/root/path/to/page and nothing seems to work. I'm so confused. I don't need a particular domain to redirect to my AMI so I don't need to map my domain's DNS to the elastic IP.

Community
  • 1
  • 1
  • What exactly are you trying to do? What do you mean by "redirect a router"? – David Levesque Jun 27 '14 at 21:04
  • Have you checked that the Security Group(s) for that instance allow access from port 80 (assuming you are looking to access port 80). Also, did you start the httpd service on the EC2 instance? – Honus Wagner Jun 27 '14 at 21:56
  • I was simply trying to get a router to redirect to a particular page on my AMI upon the first connection to it by a user. @DavidLevesque – René Alejandro Santiago Jul 01 '14 at 02:00

1 Answers1

0

Okay, so I figured out the problem with the redirection. Essentially, I have Apache running on my CentOS AMI. As Apache, I think, handles most if not all HTTP requests, the request for the particular page on my AMI was being handled by Apache. What I did was that I looked in the configuration files of Apache on the AMI which are under etc/httpd/conf on CentOS at least (I don't know about other distributions), and opened httpd.conf (full path: /etc/httpd/conf/httpd.conf).

I looked for the particular line that had the DocumentRoot (this line sets the directory from which Apache will serve files) directive and saw that it had "DocumentRoot "/var/www/html".

What I was doing wrong was that my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page instead of just ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/page because I didn't know Apache was automatically appending /var/www/html before /page.

So since my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/page, when Apache was getting the request it would append another /var/www/html and look in ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/var/www/html/page.