Solved

CentOS htaccess file question

Posted on 2013-06-14
7
624 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
Comment Utility
0
 

Author Comment

by:Johny_Brav0
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 27

Assisted Solution

by:serialband
serialband earned 166 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now