Forwarding homepage to landing page using htaccess - wordpress

I have a Wordpress site (eg. www.domain.com) that lands on the homepage. I want to change this, so it actually lands on an interior page (eg. www.domain.com/landing/). I don't want to do a standard redirect, as I still want to allow access to the homepage. I just want to change the initial landing page.
I'm assuming it's a matter of updating the ".htaccess" file, but I just want to find a solution that will still allow me to access the homepage of the site, once I've landed on the landing page.

You can do this in the wordpress dashboard/customise your site. Set your static front page to the new landing page.

Try checking the referer to make sure it's either someone who typed the URL in the address bar or clicking a link elsewhere:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?domain\.com [NC]
RewriteRule ^$ /landing/ [L,R]
You'd want this above your wordpress rules.

Related

how to rewrite non exist url to display content of dynamic page from wordpress

in wordpress normally if click domain.com/index.php?p=2
it redirect to domain.com/sample-page/
say now i like to show sample-page content domain.com/sample-page/
from non exist url
domain.com/member/abc/
domain.com/member/bbb/
domain.com/member/ccc/
but when user run any of above URL example.com/member/xxx/ in browser it will show content of example.com/sample-page/
without any redirection to example.com/sample-page/
so the address still remain in example.com/member/xxx/
please advice how to do in .htaccess or in functions.php
This sounds pretty straight forward, all you need is a single internal rewrite rule:
RewriteEngine on
RewriteRule ^/?member/.+/?$ /sample-page/ [END]
Such rule has to be implemented to be applied prior to the wordpress internal rules.

How to redirect a domain to a web page?

I have a Wordpress website => www.mywebsite.com
where I can create pages such as : www.mywebsite.com/page-hello.html
I also have a domain : hello.com
I would like to redirect the website hello.com to the page www.mywebsite.com/page-hello.html while keeping hello.com in the URL.
Basically hello.com stays in the UTL but users will see this page > www.mywebsite.com/page-hello.html
I don't think I've come across such scenario where the page being viewed will be different from the URL. If you have, please let me know.
There are two ways you can redirect the hello.com to the page www.mywebsite.com/page-hello.html.
1. Depending on your hosting company, but I think it is common for all hosting companies to have the domain redirection function. Log in to your control panel, under the domains section, you should find a link to add domain redirects. See attached image.
You can do this through your .htaccess file. Locate this in your root folder (public_html), and then add the code below:
# .htaccess
RewriteEngine on
# Require www
RewriteCond %{HTTP_HOST} ^www.hello.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/page-hello.html/$1 [R=301,L]
Hope that helps.

Too many wordpress redirects

I've inherited a page with a large multi-step form at /big-form that's passing fields to each subsequent step via POST. I need to make each step more SEO friendly, something like /form/step-[1-5]. It would also have /other-form/step-[1-5] on the same page.
I added this RewriteRule:
RewriteRule ^form/step-[1-5] /big-form/ [QSA,L]
which should push requests for the SEO pages to the already created page, but it 404s. Looking through the redirect logs, it's catching the /form/step-1 url, redirecting that to /big-form, then doing the usual wordpress redirects through /index.php. For some reason, by the time WordPress is looking for what page to render, it's getting confused and giving up.
Is there a way to redirect all requests from the SEO friendly URLs to the actual page in WordPress?
Assuming the site does not contain any other URLs containing "step", you could just do:
RewriteCond %{REQUEST_URI} step
RewriteRule .* /big-form/ [R=301]

Permalink for Homepage

I have a simple wordpress question. Currently I have a site with a static home page, when I visit my site examplesite.com the URL reads what it should which is examplesite.com, would it be possible to give this static home page a permalink so that when I load the site it automatically turns to examplesite.com/customlink. What I am saying is I still want the same home page and the same URL to reach it, I just want a specific permalink to appear. I can edit permalinks for all other pages but since this is my homepage I see no option to do it automatically in wordpress.
Inside settings you can set static pages as default.
For this you'll need .htaccess, e.g.
RewriteEngine On
RewriteBase /
RewriteRule ^$ page-you-want [L,R=301]
So any requests to root will get moved to the permalink you want. You don't need to set your home page to a static page/front page.

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

Resources