Solved

CentOS htaccess file question

Posted on 2013-06-14
7
635 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
  • 4
  • 2
7 Comments
 
LVL 23

Accepted Solution

by:
savone earned 334 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 334 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 29

Assisted Solution

by:serialband
serialband earned 166 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 108
.htaccess file settings 4 63
WEB Farm 6 76
wamp versus xampp 4 63
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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 Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

831 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