Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

.Htaccess on web server not working?!

Posted on 2013-10-28
9
Medium Priority
?
660 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 111

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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 800 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
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 111

Expert Comment

by:Ray Paseur
ID: 39605555
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 1200 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 111

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This article discusses how to create an extensible mechanism for linked drop downs.
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.
Suggested Courses

618 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