Solved

.Htaccess on web server not working?!

Posted on 2013-10-28
9
652 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 110

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 110

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
Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

 
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 110

Expert Comment

by:Ray Paseur
ID: 39605555
0
 
LVL 35

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 110

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

687 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