Home Apache rewrite about www to non-www redirection
Reply: 0

Apache rewrite about www to non-www redirection

Matthew
1#
Matthew Published in 2017-11-12 16:29:57Z

I have a question about the Apache Rewrite module.

I am using 2 servers. One is an active server and the other is a test server, Both are completely the same, about the OS , the Apache version and Apache configuration.

First, the OS is ubuntu 16.04, and the Apache version is 2.4.29.

These servers are using redirects through the vhost file.

non-www to www redirection works well on both server.

The code like this :

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/
RewriteRule ^ - [END]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,NE,L]

However, when using www to non-www redirection, it works well on the test server, but does not work on the active server. The code like this :

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/
RewriteRule ^ - [END]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,NE,L]

It is not related to ServerAlias. both servers have same configration.

In this case, where can I find out the problem?

Sorry for my English.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.572455 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO