Solved

CentOS htaccess file question

Posted on 2013-06-14
7
642 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 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 30

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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