301 not working with child pages - wordpress

I have wordpress site that i am redirecting via entries in the htaccess file. The main page redirects work, but the child pages are not correct. Below is a sample redirect from the file.
Redirect 301 /services/additional-background-screening-services/ https://www.inlinereferencecheck.ca/services.html
The above redirect links to https://www.inlinereferencecheck.ca/services.html/additional-background-screening-services/ on the target site
have I configured something wrong? The top level links work fine

Don't use mod_alias' Redirect to redirect with changing URLs, use mod_rewrite. mod_alias is made for cases where you want to do simple redirects from https://example.com/* to https://example.org/, but keep the local URL structure.
Mod_rewrite allows much more fine tuned control. Change it to something like this:
RewriteEngine On
RewriteRule ^services/additional-background-screening-services/$ https://www.inlinereferencecheck.ca/services.html [R=301,L]
And make sure that you put it before the Block of WP rewrite rules.

Related

Redirect URL without changing file served to user

I need to change the url on a website from /blog/contact to just /contact
But I still need application to serve the content as if the user is still accessing the original URL.
Is it possible within .htaccess to change the URL without changing any of the architecture or logic of the backend? Kind of like a permanent 301 alias?
Thanks
I found the solution to this with the following rule.
RewriteRule ^blog/contact/$ /contact [L]

Wordpress Multisite url remapping

I'm currently using a complex multisite setup. I have the site as the landing page/blog and another site for the main functionality. The subdomain of the main site is set to /dashboard/ so every other page that loads after has the dashboard slug in it. IE www.name.com/dashboard/post-a-project.
Is there was a way to make the website appear as www.name.com/post-a-project while not interfering with the landing page site? This is mostly for aesthetic purposes.
Try and use this in your .htaccess file:
RewriteEngine On
RewriteRule ^dashboard/(.*)$ /$1 [L,R=302]
I've set it to a temporary redirect using R=302. If this works for you then change it to R=301 to make it a permanent redirect.
Make sure you clear your cache before testing this.

Wordpress permalink / previous URL issue

My work has recently converted their website to run on Wordpress. The old website was made in ASP. Our marketing department have advertised a specific URL for an event, but now that URL has changed.
The old URL is: /who-are-you/stem-intro.aspx
The new URL is: /stem2014/
Can I used my htaccess file to make the first URL go to the second url without an .aspx file existing?
Thank you for your help.
Yes you can use this rule on top of your WP .htaccess (just below RewriteEngine line):
RewriteRule ^who-are-you/stem-intro\.aspx$ /stem2014/ [L,NC,R=301]
Can be performed easily with a 301 redirect in .htacess, especially if this is a one off thing
Redirect 301 /who-are-you/stem-intro.aspx http://www.YOURSITE.com/stem2014/

domain redirect to a page and rewrite url of landing to keep orgin domain

this it might be easy but I'm not sure how to achieve it (nor if it's actually possible..)
I've made a page in wordpress, with a custom template design, and not linked with the rest of the website, so it's a landing page which actually has nothing to spare with the base website.
I've bought a domain and redirected with a 301 to this page (to pass seo from that page as well).
the problem is that now I'd like to have the url of that page rewritten in order to be the same of the one I've bought, so when landing in that page, viewers won't notice that they are in another domain.
basically I want that a domain like this
my-new-domain.com
which redirects to this page (I've done this)
maindomain.com/landing-page/
and once you're there, the url displayed is:
my-new-domain.com
the page is wordpress, so I need it to keep passing the variables while the url is rewritten.
but I don't need it to handle sub-pages, as the page is a single landing page.
can I do this with an htaccess rule? and if yes, could you please tell me how this rule should ne written?
Thanx to anyone who'll help!
Andrea
You could use mod_rewrite for this
RewriteCond %{HTTP_HOST} my-new-domein.com [NC]
RewriteRule ^ /landing-page [L]
The first rule is the condition, so if the domein (http host) matches your domein the second line get executed, [NC] means no case, so my-new-domain.com and MY-NEW-DOMAIN.com both work
The second rule has 3 parts
^
as another condition (always matches)
/landing-page
that's the page which is passed to wordpress
[L]
means this is the last rule to be executed, handy when multiple rewrite rules at in the .htacess
Edit:
In addition, if you want mydomain.com/landing-page to show it's content but with my-new-domain.com in the url bar use the following to redirect to my-new-domain.com
Redirect 302 /landing-page http://my-new-domain.com

Custom mod rewrite (rewriting urls for WP multisite network) in .htaccess

I'm having this strange problem.
WP Multi Site Network has been created and pages that existed before were moved into it.
Everything works fine except, in old pages that was coded entirely in html, subsites were of format:
http://domain-a.com/subsite1.html
http://domain-b.com/subsite2.html
but now with WP pretty links they look this way:
http://domain-a.com/subsite1
http://domain-b.com/subsite2
Seo agency would like to make automagic rewrite of old links to new one. I have found sample htpassword redirrect that looks this way:
RedirectMatch 301 (.*).html$ http://domain.com$1/
but it will not work correctly because there is domain name on right but none on the left.
I understand, that for each domain I should create different rule, because proppably it cant be done in one rule globally, but either case I dont know how to do it correctly.
In theory rewrite should take any address that is with .html at the end and rewrite it to exact same without .html at the end.
Instead of your rule try this rule:
RedirectMatch 301 ^/(.*).html$ /$1/

Resources