How to remove a redirect in .htaccess - wordpress

I need to build a website for someone, but it is currently redirecting to an appointment booking software. I checked the .htaccess file and there is some sort of redirect code, not sure how to remove it. I tried replacing the entire .htaccess file with a blank one, and every page on the site said "Page not found". Any suggestions? This is what is currently in the .htaccess file.
RewriteOptions inherit
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^suitezen\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.suitezen\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/www\.massagebook\.com\/Bowling_Green\~Massage\~IBTsuitezenmedicalspa$1" [R=302,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/www\.massagebook\.com\/Bowling_Green\~Massage\~IBTsuitezenmedicalspa$1" [R=301,L]

Any line with a RewriteRule and the [R] flag (in your case written as [R=302 for a temporary redirect and [R=301 for a permanent redirect) is a rewrite rule that tells apache to redirect to the given url. The RewriteCond lines before the rule modify when the RewriteRule after it is executed. In your case you have two redirect rules:
RewriteCond %{HTTP_HOST} ^suitezen\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.suitezen\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/www\.massagebook\.com\/Bowling_Green\~Massage\~IBTsuitezenmedicalspa$1" [R=302,L]
and
RewriteCond %{HTTP_HOST} ^.*$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/www\.massagebook\.com\/Bowling_Green\~Massage\~IBTsuitezenmedicalspa$1" [R=301,L]
Delete those and delete the cache of your browser to see Wordpress again. I see that there are some conditions related to cpanel that are not usually part of a Wordpress installation (see the official wordpress site for an example of the default .htaccess). If for some reason the redirects get re-added to your .htaccess, dive into cpanel to see if there is a configuration option there.

Related

HTTP to HTTPS - Too many redirects

I have a site with Wordpress. I need some single page to redirect HTTPS
I get code form stackoverflow and put in .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /online-order-auto [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/online-order-auto [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^(www\.)?site\.com\.swtest\.ru$
RewriteRule ^(.*)$ http://www.site.ru/$1 [L,R=301]
The browser wrote "ERR_TOO_MANY_REDIRECTS".
I cant understand whats a problem
Try this. I've been looking all over and this is the only way I could make it work...
#non-www. http to www. https
RewriteCond %{ENV:HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
#non-www. https to www. https
RewriteCond %{ENV:HTTPS} on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]

htaccess rewrite doesn't work after installing WordPress

I've recently installed WordPress. Since I want it running from the root directory and like some nice looking permalinks i've added a new section to my htaccess file on the httpdocs of my server.
Since this time the redirect for other domains isn't working anymore.
This is the current code:
Options +FollowSymLinks
RewriteEngine On
#Redirect to other DOMAINS
#----------------
RewriteCond %{HTTP_HOST} (www\.)?example1.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/e1/.*$
RewriteRule ^(.*)$ /e1/$1
RewriteCond %{HTTP_HOST} (www\.)?example2.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/SR/.*$
RewriteRule ^(.*)$ /SR/$1
#ALTERNATE DOMAINS
# ---------------
RewriteCond %{HTTP_HOST} ^www.gw.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^gw.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.cb.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cb.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
The WordPress site works as it should. Alternate domains works as well. However, the other two sites are totally out of the running, now displaying the main wordpress website.
If I change RewriteRule . /wordpress/index.php [L] to RewriteRule . /index.php [L] it will return an internal server error.
Anybody got a clue what's the mistake?
adding the flags
[R=301,L]
to the first two rules worked!

wordpress and htaccess 301 redirect without admin

I'm trying to redirect my entire blog to a new domain without redirecting the admin area.
The code I use is as follows:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^old-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp-login
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
But still I'm getting redirected to the new domain when I go to old-domain.com/wp-admin
Can anybody help?
Thanks.
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^(.*)?wp-login\.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
This worked for me...
# Redirect all requests except wp-admin
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(.*)?wp-login\.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
RewriteCond %{REQUEST_URI} !^/(wp-includes/.*|wp-admin/.*|wp-content/.*)$
RewriteRule ^(.*)$ http://new.com [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

Allow stylesheet in rewrite engine

I have a temporary coming soon page while i test our new website. i have setup an redirect in the .htaccess file using the below code. Problem is that it doesn't get the stylesheet. Any help appreciated, thanks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^7\.150\.99\.110
RewriteCond %{REMOTE_ADDR} !^82\.31\.116\.41
RewriteCond %{REMOTE_ADDR} !^localhost
RewriteCond %{REQUEST_URI} !/coming-soon.php$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /coming-soon.php [R=302,L]
</IfModule>
Add .css and .js in excluded list:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^7\.150\.99\.110
RewriteCond %{REMOTE_ADDR} !^82\.31\.116\.41
RewriteCond %{REMOTE_ADDR} !^localhost
RewriteCond %{REQUEST_URI} !/coming-soon.php$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js) [NC]
RewriteRule ^ /coming-soon.php [R=302,L]

htaccess force ssl except for rss feeds

My site currently forces SSL everywhere. This is the way that I want except that it is causing issues with my RSS driven newsletter and feedburner. Due to this I need to make exceptions for my feeds.
Can someone help with the proper htaccess rules to pull this off?
My feeds are
/feed
/shop/feed
/forum/discussions/feed.rss
Here is my condition for forcing SSL. This works except that all RSS feeds are forced to.
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
I tried the following but it did not seem to work correctly.
# Force SSL
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/forum [OR]
RewriteCond %{REQUEST_URI} !^/feed [OR]
RewriteCond %{REQUEST_URI} !^/shop/forum [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
Your help is greatly appreciated!
Update: This is my current .htaccess file in the root of my server. This is currently redirecting http://photoboothowners.com/feed to https://photoboothowners.com (notice it is dropping the feed directory).
RewriteEngine on
# Use PHP5CGI as default
AddHandler fcgid-script .php
RewriteCond %{HTTP_HOST} ^buyaphotobooth\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.buyaphotobooth\.net$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/starting\-a\-photo\-booth\-business\-build\-or\-buy" [R=301,L]
RewriteCond %{HTTP_HOST} ^photoboothforums\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothforums\.com$
RewriteRule ^/?$ "https\:\/\/photoboothowners\.com\/forum" [R=301,L]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/forum [NC]
RewriteCond %{REQUEST_URI} !feed [NC]
RewriteRule ^/?(.*)$ https://photoboothowners.com/$1 [R=301,QSA,L,NE]
RewriteCond %{HTTP_HOST} ^photoboothowners\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.photoboothowners\.com$
RewriteRule ^how\-to\-use\-our\-premium\-print\-designs\-in\-breeze\-dslr\-remote\-pro\/?(.*)$ "https\:\/\/photoboothowners\.com\/how\-to\-use\-our\-photo\-booth\-template\-designs\-in\-breeze\-dslr\-remote\-pro$1" [R=301,L]
RewriteOptions inherit
# 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
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^shop\/photo\-booth\-layouts\-and\-samples\.html$ "https\:\/\/photoboothowners\.com\/shop" [R=301,L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Your rules are using OR so they read as:
if server port is 80 and the request is not forum OR it is not feed OR it is not shop/forum
That's going to match everything. Get rid of both of the [OR] so that the match reads:
if server port is 80 and the request is not forum AND it is not feed AND it is not shop/forum
EDIT:
Per your updated question, the following line is missing a slash:
RewriteCond %{REQUEST_URI} !feed [NC]
should be
RewriteCond %{REQUEST_URI} !/feed [NC]

Resources