create a htaccess rewrite rule from subdomain to subfolder - wordpress

There was some discussion on this topic which i have read through, but it does not help my current situation.
Problem.
I have a wordpress mu site located on a subdomain (site.website.com)
The first subsite i created is (site.website.com/subsite1)
I want to serve (site.website.com/subsite1) from (website.com/subsite1)
I know this is possible because i already do it in a different way. I have a wp mu located in a subdolder.(site.website.com/mainsite) and have created subsites at (site.website.com/subsite1) (site.website.com/subsite2) (site.website.com/subsite3)
I did this by manaually editing the site url in wordpress admin, then creating a folder in the home directory, with the same name as the subsite and placing a htaccess file with rewrite rules in it.
Now i want to achieve the same thing with a multisite install in a subdomain, pointing to a folder in the apex domain with a htaccess file in it.
The problem is that im lacking in knowlege when it comes to rewrite rules. Any experts please step up.

Related

.htaccess reditrect subdirectory page to root

I got a website running and in the subdirectory domain.com/blog/ I installed a Wordpress blog website. The subdirectory contains dozen of blog articles, for example
domain .com/blog/testing
domain .com/blog/example
domain .com/blog/article1
domain .com/blog/article2
And what I am trying to do is to rewrite and redirect (a single page) domain.com/blog/example to domain.com/example
Any way to do this?
It seems javascript redirect is better than htaccess redirect for your case.
Simply edit your article using a code editor in wordpress.
<script>window.location = "http://www.yourhomepage.com";</script>

Moved Wordpress to a subdirectory, don't want site-url to redirect to my subdirectory

I've searched a while but couldn't find an answer to this question yet. I had WP originally installed in the site root and moved it to a subfolder and went through the common steps necessary. I do this because I want to run wordpress only for blogging reasons and keep another HTML site as my main project that I want to access through my domain www.example.com and the wordpress blog through www.example.com/blog/
I moved the WP system therefore to /blog and changed the site address and wp address to that folder and followed the usual steps. Everything works just fine. Still when I enter my domain it redirects automatically to the /blog subdirectory and not to the site that lies in the root that has a index.html. There is no .htaccess file in the root or anything similar. How is that possible? Happy about all suggestions.

Redirect image links from old blog (Wordpress multisite)

I have the following scenario:
Everything runs on a wordpress multisite
I used to have a blog on domain A
The blog posts from domain A got transferred to a new blog on domain B. The images on this new blog were still pointing to domain A and were working fine, until...
I created a new website on domain A with a different ID
Now the images on domain B point to domain A, to the upload folder of the old ID and they don't work anymore. I just copied the files from the old blog over to my new blog's ID's upload folder.
Now I guess I need to edit my htaccess file, which is the reason for this question. What's the code I need to use and where do I put it (I guess it goes in the main WP htaccess file)?
I need to redirect all image links from
http://domaina/wp-content/uploads/sites/5/XXXX/XX/XXX.xxx
to
http://domainb/wp-content/uploads/sites/9/XXXX/XX/XXX.xxx
I guess an alternative would be to do it in SQL and rewrite the permalinks, but that's quite high risk and I would prefer the htaccess solution...
If you want to use .htaccess than just put the redirects following the example
Redirect 301 /old-page.html http://new-domain.ru/new-page.html
and yes, use the main .htaccess in the root WP directory

htacess for root folder with wordpress install and subdirectory for another domain

I have a wordpress install in my website directory e.g.( public_html/wp-content, public_html/wp-admin, public_html/wp-includes) and I have a subdirectory to which points to another domain public_html/anotherdomain.com
I don't want the another domain messing up the root wordpress install.
ex. anotherdomain.com should only go to public_html/anotherdomain.com and originialdomain.com should access public_html folder excluding the anotherdomain.com.
My question is what is the best approach for this?
using htaccess?
using the cpanel addon domain and make a subdirectory for the wordpress install?
If you use .htaccess you can block access to anotherdomain.com from your wordpress site. This will work but is kind of a sloppy hack and doesn't plan for the future pretty well. Are you going to keep doing this when you get more domains and install them.
The cleaner way to do it is what I think you are saying in your number 2. Give the wordpress site it's own directory that is a peer with anotherdomain.com. This way it will work the same if you have 1, 2, or 10 domains.

Sub domain redirect (htaccess)

There is soooo much information about htaccess redirect that I think I'm lost.
Here is my current structure
/web/
/web/CMS/
In the root I have a vBulletin forum and in /CMS/ I have wordpress. (Ideally I should have vBulletin in a /FORUM/ folder maybe?)
I'd like to setup something like this:
www.domain.com OR domain.com goes to /web/CMS/
forum.domain.com OR forums.domain.com goes to /web/
Then any other subdomain goes to /web/CMS/ (as I'll be using the multi site network of Wordpress)
I have 2 questions:
What would be the best structure for this? Maybe I should have my CMS as root and my forum in a folder?
How can I do an htaccess that does the job? (do I also need one in /web/CMS/?)
Thank you so much in advance.
If you have vBulletin in your root and you want it to go to forums, you should consider moving it into it's own directory called /forums. Inside the /forums directory, you'll have a .htaccess file generated by vBulletin.
You can keep your WordPress inside /CMS. WordPress will and should have its own htaccess file.
Now if you want to set a subdomain, you'll have to look into your DNS settings and at a minimum setup an A record. If you're on cPanel, this is pretty simple to do inside your DNS Zone section.

Resources