mask domain in url using .htaccess - wordpress

Heya thanks for any help in advance
So i have 2 domains both with same hosting company namesco called dmfoundation.org.uk and dmtrust.org.uk.
dmfoundation.org.uk(no cpanel is apache http server) has all the files for my wordpress site and dmtrust.org.uk (cpanel) has no files inside it.
what i want to do is redirect dmtrust.org.uk to dmfoundation.org.uk but i want all the urls to appear as dmtrust.org.uk/whatever file name.
rather than displaying dmfoundation.org.uk/whatever filename.
any question feel free to ask.
Cheers,
Grant

First you'll need to point DNS from dmtrust to dmfoundation hosting.
Then in wp replace the site url to dmtrust (and eventually all links/src to dmfoundation in database).
Finally, in your .htaccess, at the root of you wp on dmfoundation, add a redirection to match every pages.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://dmtrust.org.uk/$1 [R=301,L]
</IfModule>

Related

Redirect wordpress site to www from non www on wordpress server

I am working on a Wordpress project which is deployed on wordpress.com hosting. Simply I want to redirect the website from (with SSL)non-www to (with SSL) www.
I have searched over web and there are plenty of plugins who does the job, but there is a problem with wordpress hosting, it redirects back from www to non-www and resuslts error "too many redirects".
I tried to change settings from admin panel settings> General > site url. But its disabled there, I cannot change it. This option is enabled to change on other hosting servers but not on wordpress.com hosting.
I tried it to do that through htaccess but still not working.
if information is not enough I can provide more info.
Kindly help me out with this problem.
Thanks in advance!
This is simple with .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS}=off[OR]
RewriteCond %{HTTP_HOST}!^example\.com$
RewriteRule ^(.*)$"https://example.com/$1" [R=301,L]
# remaining htaccess mod_rewrite CODE for WordPress
</IfModule>

.htaccess to rewrite to subfolder & different URL

I've got a site that's setup as a WordPress network/subsite off primary url.
domain.org/subsite
I'd like to rewrite requests from a seperate DNS name - call it domain2.org - (which I control) to that subsite
domain2.org -> domain.org/subsite
I've seen examples of using .htaccess rewrites to route to subfolder, but can't figure out specifics on how to do this.
Thanks for looking.
put this code in your DOCUMENT_ROOT/.htaccess file of domain2:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.org$ [NC]
RewriteRule ^ http://domain.org/subsite%{REQUEST_URI} [R=301,L,NE]
I had an experience working with wordpress multisite which is hosted at godaddy.
Godaddy has an option for the registered domain say for eg http://domain2.org asked for hosting server point or url. In the url field paste it http://www.domain.org/subsite
So check with your hosting provider.

static to static url rewrite with htaccess with wordpress

I have a wordpress site with its own .htaccess automatically generated (because I'm using permalinks), than, my web-admin has configured apache to redirect any third level domain to my site, ie :
http://lol.example.com redirects to http://example.com
and than .htaccess with permalinks rules does the rest.
Now I want to write a rule in the .htaccess file that, when a user types a specific third level domain, redirects to a specific subfolder of my site, ie:
http://sprock.example.com/ redirects to http://example.com/mysprockfolder/
I know my question might sound weird, but I've never done this before so I'm quite confused.
Solved with that regex in my .htaccess:
Right before this comment (just in case you have WordPress installed):
# BEGIN WordPress
I've added the following:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?thirdlev\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/myfolder/ [R=302,L]
with a 302 redirect, everything is good!
it would be much easier for you to just go to your ftp manager and make a subdomain forward to a link. Or, you can make a redirect using php.
when redirecting make sure to add the http://www. or it will think you want to redirect to a part of your page on the site, also make sure that your subdomain has its own folder with its own files and images.

Limit web folder access to specific URL

I am hosting two different websites using one hosting package.
My initial website is self-built and runs from the public_html directory of my host let's call this 'http://www.website1.co.uk'
I also have a Word Press blog running in a folder under the public_html - so '/folder_2', let's call this 'http://www.website2.co.uk' - this URL currently points to '/folder_2' and will load the blog when entered in to a browser.
At the moment the blog is also accessible by entering 'http://www.website1.co.uk/folder_2/'.
I would like to be able to limit access to 'folder_2' to just 'website2.co.uk' - preventing somebody typing in the 'website1.co.uk/folder_2' path and being able to view the blog.
What's the best way to achieve this, bearing in mind the folder in question is running a Word Press blog.
Try adding this in your .htaccess file in folder_2
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* http://website2.co.uk
that would redirect anyone who goes to website1.co.uk/folder_2 to website2.co.uk, but if you just want them hit a 404 put this in .htaccess instead
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* - [R=404,L]
1# move folder_2 out of public_html(you really should do that).
2# rewrite all request of 'http://www.website1.co.uk/folder_2/' to 404 in htaccess
Check below link:
Redirection Subfolder Htaccess

How to run WordPress from other location on the same domain

Hi I have a domain running in WordPress,
the path to WordPress installation is /subdomain/mywordpress/ and I can access these in mywordpress.mysite.com, Now I wish to load the index page on my main domain, ie
When I goto mysite.com I want to load the Index page of the WordPress, I know if that possible, the links are always pointing to mywordpress.mysite.com, but that is what I need know. because I dont want to remove the mywordpress.mysite.com. I just need to display all posts on my main site, with same design(that is why I prefer to load the Index file of wordpress)
What about a simple mod_rewrite rule inside a .htaccess to redirect to mywordpress.mysite.com?
This should work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule . /subdomain/mywordpress/index.php [L]
You should look at this article in the Codex: Giving WordPress Its Own Directory. It addresses exactly the situation you are describing.

Resources