Redirect wordpress website with htaccess

Situation

The data is stored at http://aplhazone.myserver.com .

The domain is http://betazone.com where the CNAME record is possible (I don't have access to the server config).

Here is WordPress with its htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress

      

Desired behavior

Redirect all traffic (possibly from 301) from http://aplhazone.myserver.com AND http://www.betazone.com To http://betazone.com .

Failed attempts

Case 1

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.betazone.com$ [OR]
RewriteCond %{HTTP_HOST} ^aplhazone.myserver.com$
RewriteRule ^(.*)$ http://betazone.com/$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# END WordPress

      

Case two

Redirect 301 / http://betazone.com/

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# END WordPress

      

Common mistakes

The first

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    This problem can sometimes be caused by disabling or refusing to accept cookies.

      

Second

The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies

      

Third

Charles Error Report
Failed to connect to remote host

Charles failed to connect to the remote host. Check that your Internet connection is ok and that the remote host is accessible. Maybe your network uses a proxy server to access the Internet? You can configure Charles to use an external proxy server in the External Proxy Settings.

The actual exception reported was:

java.net.ConnectException: Connection timed out: connect

Charles Proxy, http://www.charlesproxy.com/ 

      


What am I doing wrong?

+3


source to share


1 answer


Try to run

RewriteEngine On
RewriteCond %{HTTP_HOST} !^betazone\.com [NC]
RewriteRule (.*) http://betazone.com/$1 [R=301,L]

      



The rewrite condition states that if the hostname does not start with betazone.com, redirect it to betazone.com. Therefore www.betazone.com and alphazone.myserver.com will be redirected to betazone.com

+1


source







All Articles