Solved

CentOS htaccess file question

Posted on 2013-06-14
7
628 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to solve ssl error handshake failure alert on IE 1 204
CFFILE upload help 98 158
Squid Authentication 7 69
exchange 2010 turning off 3des ciphers 2 194
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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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