Solved

.Htaccess on web server not working?!

Posted on 2013-10-28
9
639 Views
Last Modified: 2013-10-30
hi guys,

we're trying to get .htaccess to work and it isn't on our Amazon EC2 instance. Our developer has put the following code into the .htaccess file:

RewriteEngine on

# perform redirect if
RewriteCond %{HTTP_HOST} ^externalip$ [NC]
RewriteRule ^(.*)$ http://www.google.co.uk [R=301,L]

(i've deliberately hidden the external ip by commenting it above).

So when we go to the external IP address, it doesn't redirect to www.google.co.uk.

It's so important we get this working.

Any ideas guys?

Thank you
Yashy
0
Comment
Question by:Yashy
  • 4
  • 4
9 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39605416
In PHP you can test $_SERVER['HTTP_HOST'] and redirect with header().  Since we can't see the true URL because you have hidden it (why?) we can't tell if there is a case-sensitivity issue, etc.
0
 
LVL 1

Author Comment

by:Yashy
ID: 39605463
thank you sir. This is the IP 54.229.59.230. Should I change the .htaccess file from what it is right now?
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 39605492
It looks like it rewrites to /home.  Are you sure you have the right version of .htaccess (maybe a different directory?)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:Yashy
ID: 39605496
The .htaccess file which the modification has been made to is in the /var/www/html/ directory.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39605555
0
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 300 total points
ID: 39605601
Is that the ONLY content in the .htaccess file? Are there any other .htaccess files, or any other configuration lines containing the word "redirect" or "home" ?

1. Usually if an .htaccess file has incorrect instructions, you'll get an HTTP 500 error.

2. If the AllowOverride isn't turned on for your host, then the .htaccess file will get ignored.

3. When using name-based virtual hosts (where one IP address can be used for multiple domain names / virtual hosts), going to the IP address will go to the FIRST virtual host entry in your Apache configuration that uses that IP address. So it's possible that Apache is sending the user to one virtual host and you're putting your .htaccess file in a different one.
0
 
LVL 1

Author Comment

by:Yashy
ID: 39605743
thanks for all your help here.

How can I find if there's more than one .htaccess file via the command?

I have set the 'AllowOverride None' to 'AlloverOverride All'.

Also, I am unaware of any other config files have the word 'redirect' or 'home', but again....how would I find those?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39608447
How can I find if there's more than one .htaccess file?
Look in the directory listings.  It always has the same name.
0
 
LVL 1

Author Comment

by:Yashy
ID: 39611703
Guys, we worked it out.

The actual .htaccess was being completely overlooked as we weren't even getting a 500 error.

So we looked at the httpd file and in there, our developer went into the conf.d folder and there's a php.conf file which he opened and made changes to. It's now working as it should be.

Guys, thank you so much for all your input. It led us to the conclusion that htaccess is being overlooked.

Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question