Sub domain redirect (htaccess) - wordpress

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.

Related

create a htaccess rewrite rule from subdomain to subfolder

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.

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

Redirect root to subdirectory apache

I have an apache server with a WordPress website set up at root and a WordPress website in a subdirectory. I would like for the website in the subdirectory to be the default website. For example, when someone goes to www.example.com I would like for them to see the website that is actually located at www.example.com/newsite but the URL needs to stay the same, www.example.com.
Is doing something like that possible with say a 301 redirect or some other method?
check this out, you just need some htaccess changes:
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
You can simply move/copy the files to the root folder in case you are having root access.
cp -pR /path/to/rootfolder/subdirectory(wordpress)/* /path/to/rootfolder/
Thats it. Don't complicate by putting redirects.
In case you are having a control panel like cPanel, Its easy to put redirects. But as far as I concern moving/copying the files are more reliable.

wp-admin and wp-login.php - 404 error for those who do not administrator (wordpress + htaccess)

I try to hide the traces as wordpress on my website for security reasons. Does anyone know how to create a rule using htaccess, according to which a third party user (with a different ip) redirected to on /404.php if he visits the wp-admin and wp-login.php ... I've seen third-party plug-ins (?) To address this problem, but I do not want to create an extra load on the CMS.
you can use simple redirect in .htaccess like this
Redirect 301/wp-admin/ http://www.yourwebsite.com/404.php
But if you're trying to completely hide wordpress it requires a little bit of technical work...what I did in mine, is search every files in the wp-include and wp-content folder as well as the root folder that contained the wp-login.php and /wp-admin/somefolder words, and change everything to a file or folder to a name of your choice that no-one can guess. Although you have to be very careful as not to change an important code there...

Resources