Wordpress site within a wordpress site, .htaccess? - wordpress

I was asked to move one working WP site (site 2) onto a folder of another WP site (site 1)(because the first site is being blocked in China and the second isn't).
so the complete URL ended up being www.site1.com/site2
I managed to do so but the links on the second site are no longer working, they show a 404 from site 1 but the URL seems OK
www.site1.com/site2/path_to_page_on_site_2 -> 404
I assume it is because of the .htaccess from site 1:
# Redirect images
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^font/(.*)$ /wp-content/themes/site1/font/$1 [L]
RewriteRule ^timages/(.*)$ /wp-content/themes/site1/image/$1 [L]
RewriteRule ^images/(.*)$ /wp-content/uploads/images/$1 [L]
RewriteRule ^videos/(.*)$ /wp-content/themes/site1/video/$1 [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Site 2 has a "standard" .htaccess from WP
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
if it is an htaccess problem, how can i stop the htaccess from site 1 affecting site 2?
if it is something else, how can i fix it?
thanks in advance

I managed to do what i was after thanks to Nikola's comment. This is the final htaccess file for site2
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site2/index.php [L]
</IfModule>
# END WordPress
I wanted to redirect all the calls to site2 to the appropriate folder so relative paths were not affected but was not able to do it with htaccess, so i had to do a replace in the database to make them absolute.

Related

WordPress multisite | ROOT redirects to SUBFOLDER

I have a problem on my WordPress multisite. There's a WordPress installation on the root folder (public_html) of my domain and it was working fine.
We had to install a second WordPress site in a subfolder (public_html/subfolder).
If I try to access example.com/subfolder, the second website works fine.
If I try to access example.com, it redirects to example.com/subfolder. I no longer can access the first website.
ROOT .HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
SUBFOLDER .HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
# END WordPress
Can someone explain how to prevent this redirect?
Thanks!
Try to delete (or rename) root .htacces.

subfolder wordpress htaccess

I have a ubuntu server that has a wordpress installed on with link "https://gditac.com"
after that I installed another wordpress on subfolder like "https://gditac.com/news" but the problem is the second website redirects on first and show 404 not found page. I searche a lot but couldn't solve my problem.
here the htaccess for the root website :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
and here the htaccess for subfolder website :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
</IfModule>
# END WordPress
any idea whats going on?
I think best way is to create a subdomain e.g. news.gditac.com, install there your wordpress and make a permanent redirect from https://gditac.com/news to https://news.gditac.com
If you really want to install it on a subfolder then read this article:
https://wordpress.stackexchange.com/questions/134839/is-it-possible-to-install-wordpress-within-wordpress-installation
Alex

Wordpress two sites in different folders - redirecting issue

I have two Wordpress websites, one is in root and another in subfolder.
example.com and example.com/newsite
When I open example.com/newsite/ all is working good, but if I open any pages likes
example.com/newsite/about or example.com/newsite/contact
browser auto redirect to
example.com/about and example.com/contact
I changed all paths, address, home url in config and sql to example.com/newsite/
Root htacess looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
htaccess for /newsite looks same.
Can anybody help me?
You should be using a different rewritebase if it's in a sub directory. Your wordpress rules in side htaccess under /newsite should look something like this.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Redirect 301 all files from a folder to one file?

Good day everyone,
On my Wordpress website, I had a plugin that transfered external links through virtual site.com/go/abc123xyz style links.
I have removed the plugin but obviously, when I checked G webmaster tools, there were many Not Found errors for all of those virtual links.
All I wish to do is redirect all of those /go/links to one particular external link. I'm looking for a redirection rule which will redirect all links from the virtual /go/ folder to my specified link.
Would be really thankful if anyone can help me. Thanks!
Try adding:
RewriteRule ^go/(.*) www.mysitedotcom/out/link.php?id=$1 [R=301,NC,L]
To your default htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
So it should look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^go/(.*) /out/link.php?id=$1 [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I hope that answers your question and helps you.

Redirection Loop Error in Wordpress Website

I have switched to a new website design (to wordpress from static),so in-order to map old pages to new pages i edited the htacess file,But it resulted in a redirection loop and the site was down after days.So i removed the htacess file.How am i supposed to do proper redirection.
Here are the Redirection code contents from the htacess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect /test1.htm http://www.mysite.com/test1
Redirect /test2.htm http://www.mysite.com/test2
Redirect is a command from a different module than RewriteRule is. This will cause problems quite often.
Just do the redirect using RewriteRule.
#just in case test.html still exists in the filesystem
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^test1\.htm /test1 [L,R=302]
RewriteRule ^test2\.htm /test2 [L,R=302]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>

Resources