Solved

.Htaccess on web server not working?!

Posted on 2013-10-28
9
648 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
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

737 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