Redirect homepage to specific subdirectory - wordpress

I have a wordpress site and I need to redirect the homepage "http://members.slateadvisers.com/"
to the registration page
"http://members.slateadvisers.com/?action=registeruser&subscription=1"
How can I do this with htaccess?

Insert this rule on top of all the rules just below RewriteBase line:
RewriteCond %{HTTP_HOST} ^members\.slateadvisers\.com$ [NC]
RewriteRule ^$ ?action=registeruser&subscription=1 [L,R=301]

Related

Exlude a page from htaccess Rewrite rule

I've a WordPress install where I have redirected all pages (except the wp-admin and wp-login) to a different url.
I want to exclude one page (called /your-login) from being redirected. This page is in effect the wp-admin page where the login slug has been changed.
How can I exclude this page from being redirected in the htaccess file?
The current code I'm using to perform the redirects in the htaccess file is:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(/wp-admin|.*wp-login\.php.*) [NC]
RewriteRule (.*) https://mywebsite.co.uk/$1 [R=301,L]
where mywebsite.co.uk would be the site being redirected to.
Thanks!
You can try this,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(/wp-admin|.*wp-login\.php.*) [NC]
RewriteCond %{REQUEST_URI} !^/your-login/$
RewriteRule (.*) https://mywebsite.co.uk/$1 [R=301,L]
Another solution is a plugin
https://wordpress.org/plugins/redirection/

.htaccess file exact match and not exact match

I just moved to a WordPress site. I used to have a static site and a WordPress blog on a subdomain (blog.example.com). I'm using the code below, which is redirecting all of my blog posts to my new website perfectly fine. Is there any way to make an exception for the main blog page? To be specific, I need the code below to apply to all my posts, categories, etc. (which it already is), but I need my old blog home page (blog.example.com) to 301 redirect to my new blog homepage (example.com/blog). Just to be very clear, my posts, etc. are NOT using blog in the permalink.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
</IfModule>
UPDATE: Thanks, Olaf! Got this working with your advice. Here is my final code for anyone else looking for an answer.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^$ http://www.example.com/blog [R=301,L]
RewriteCond %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
</IfModule>
Put the most specific rules at the beginning. In your case, prepend the existing rule with the redirect for the main page
RewriteCond %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^$ http://www.example.com/blog [R,L]
When everything works as it should, you may replace R with R=301. Never test with R=301.

Force add 'https://' in my cspecific pages by htaccess

I have a website built with WordPress cms, i want to add https:// on my contact page by htaccess file of website. I have try different think but i an not able to do it. Here is the site link
Please share if have any idea!.
If you have https enabled for your domain, it would be a good idea to use it for the entire website, not just for one/some pages only.
To redirect all existing pages from http to HTTPS, you can use the following .htaccess code snippet:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>
In your .htaccess - add this logic.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} contact
RewriteRule ^(.*)$ https://alacartesites.com/contact/$1 [R,L]
Ref: http://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file, it worked for me. I verified. Please use the below one.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(contact|contact/)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Redirect if someone try to access my sitemap

My sitemap location is on this link. this sitemap was generate by plugin and not exists on directory.
I want to redirect to home page or image from other website if someone trying to access, only bot can access it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !(googlebot|msnbot|baiduspider|slurp|webcrawler) [NC]
RewriteCond %{REQUEST_URI} ^/sitemap.xml [NC]
RewriteRule ^ http://www.example.com/ [R=301,L]
</IfModule>
Add this line in your htaccess file
RewriteRule ^sitemap.xml$ index.php [L]

how to redirect wordpress posts to new domain

i need to redirect all posts from the old wordpress to a subdomain
ex:
old-domain/category/photos should redirect to new-domain/category/photos
but if old-domain/ only this should not redirect to the new url
Try adding the following to your htaccess file in the root folder of old-domain
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/$ [NC]
# not assets e.g images
RewriteCond %{REQUEST_URI} !\.(css|png|gif|jpe?g|js)$ [NC]
RewriteRule (.+) http://new-domain/$1 [L,R=301]
Edit: modified rule so everything except the home page is redirected

Resources