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

x
?
Solved

CentOS htaccess file question

Posted on 2013-06-14
7
Medium Priority
?
653 Views
Last Modified: 2013-07-04
I am trying to use an .htaccess file on my server to redirect www. requests to a URL without www..

I have made the .htaccess with htpasswd on my CentOS 5.8 server with the required 301 redirect line in it although it does not work.

I think the redirect does not work because it is not using the htaccess file at all i.e. I try to add junk to the htaccess to test if it is in use (website would not work with junk), and nothing happens.

Please suggest how I solve this or any more information that you require.

Regards
0
Comment
Question by:Johny_Brav0
[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
  • 2
7 Comments
 
LVL 23

Accepted Solution

by:
savone earned 1336 total points
ID: 39247429
0
 

Author Comment

by:Johny_Brav0
ID: 39247810
Hi thanks for the link but I looked at that already.

As I cannot get the .htaccess file to be used by the server I am trying to put a redirect in the httpd.conf file instead.

So I add:
Redirect / https://mywebsite.co.uk

The problem is that the website is then made inaccessable when  I try to browse to it.

Please advise on this approach
0
 
LVL 23

Assisted Solution

by:savone
savone earned 1336 total points
ID: 39247982
So you are trying to redirect www.domain.com to domain.com (without www)?

Try this in your httpd.conf file:

<VirtualHost *>
  ServerName www.example.com
  Redirect 301 / http://example.com/
</VirtualHost>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Assisted Solution

by:serialband
serialband earned 664 total points
ID: 39249601
You need to change Allow Overide None to Allow Overide All to your directives in the httpd.conf file.

<Directory /var/www/>
.
.
.
AllowOverride All
.
.
.
</Directory>
0
 

Author Comment

by:Johny_Brav0
ID: 39250456
Hi, thanks for the replies.

I will try the virtual host one on Monday back at work.

The AllowOverride All idea I have tried although if I did that with another directory within the httpd.conf file would it disable the /var/www one? Just an idea.
0
 

Author Comment

by:Johny_Brav0
ID: 39252480
The reason I require the redirect is that we only have certificates for the URL without the www..

So I am trying to redirect to the URL with certificates so there are no certificate warnings.

I tried (exact code):
<VirtualHost *>
  ServerName www.nine23appstore.co.uk
  Redirect 301 / http://nine23appstore.co.uk
</VirtualHost>

And no luck, I also tried:

<Directory "/var/www">
 Options Indexes FollowSymLinks MultiViews
 AllOverride All
 Order allow,deny
 allow from all
</Directory>

With no luck.

On a CentOS setup the hosted files are in www I take it where the .htaccess file should be also?

Many thanks
0
 

Author Comment

by:Johny_Brav0
ID: 39259038
Silly me, turns out I was using the wrong directory in CentOS however it was a www directory so that threw me.

Got the .htaccess file working although I need a wildcard certificate to cope with both URLs as the browser gives a warning when the new redirect occurs.

Thanks anyway
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

610 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