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/
Related
I'm trying to redirect and entire wordpress site to a new domain EXCEPT one blog post, and the admin pages.
I've searched this site multiple times for various fixes, and across google searches. nothing has worked yet.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/blog-post-I-want-to-stay-on-old-domain/
RewriteCond %{REQUEST_URI} !=/wp-login.php
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
</IfModule>
I expected to be redirected with a full URL to a new domain, so oldsite.com/blog-post-1 would redirect to newsite.com/blog-post-1.
This works.
I expected the /wp-admin/ and the wp-login.php sections of the site to stay active without a redirect so I can continue editing the site if needed.
This works.
I expected oldsite.com/blog-post-I-want-to-stay-on-old-domain/ to not redirect, and be ignored, according to the ReWriteCond.
This does not work.
Instead it redirects to newsite.com/index.php and then newsite.com/
What have I done wrong?
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !wp-login|wp-admin|blog-post-I-want-to-stay-on-old-domain
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
</IfModule>
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]
After setting up Wordpress to use permalinks (which added some lines to my htaccess file), I got confused how to redirect a subdomain to a subfolder (astro.aspiracoesquimicas.net should redirect to aspiracoesquimicas.net/astro): what I had tried (and worked) before doesn't work anymore:
RewriteCond %{HTTP_HOST} ^astro\.aspiracoesquimicas\.net$
RewriteCond %{REQUEST_URI} !^/astro/
RewriteRule (.*) /astro/$1
Now I get a 500 Internal Server Error with the subdomain. I don't know about htaccess configuring and don't understand what changed because of Wordpress.
I'd also like to redirect blog.aspiracoesquimicas.net to the main domain aspiracoesquimicas.net
How can I do it?
Make sure you add the L flag to the rule and make sure you place the rules BEFORE the wordpress rules:
RewriteCond %{HTTP_HOST} ^astro\.aspiracoesquimicas\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/astro/
RewriteRule (.*) /astro/$1 [L]
RewriteEngine On .
RewriteCond %{HTTP_HOST} !^astro\.aspiracoesquimicas\.net/
ReWriteRule ^(.*)$ https://aspiracoesquimicas.net/astro/$1 [R=301,L]
use this method
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]
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