Moved Xenforo from root to folder, added a WordPress in the root. Now massive 404 from Google search result

Sanmu

Active member
Hi, I just moved Xenforo from root to folder, added a WordPress in the root. Now massive 404 from Google search result.

I am using Nginx.​


Before: xenforo.com

Now: xxx.com/xenforo

I have massive 404 problems when reaching these urls from Google:

xenforo.com/whats-new/
xenforo.com/resources/
xenforo.com/members/
.....

If you are on the website, every link works well.

Work I have done:

1. Added below codes
Code:
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /forum/ [R=301]
to xxx.com/xenforo/.htaccess

2. Set up Pseudo-static on the service side:

Code:
location /
{
     try_files $uri $uri/ /index.php?$args;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;


location /forum {
if (!-e $request_filename){
rewrite ^(.*)$ /forum/index.php?s=$1 last; break;
}
}
location ~ ^/(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt)/ {
deny all;
return 404;
}

3. Updated the details for the license in customer account.

Read many times the 5th point: https://xenforo.com/community/threads/frequently-asked-questions.5183/#post-180455

But can not redirect from xxx.com/resources/ to xxx.com/forum/resources/

Sorry, I am a little stupid.

Please help If you know how to deal with it. Thank you so much in advance!
 
Last edited:
Solution
If it was .htaccess / Apache, you would use:

$1 instead of just $ in the rewrite rule, so try:

Code:
rewrite ^/resources/(.*)$ http://www.mydomain.com/forum/resources/$1 permanent;
rewrite ^/threads/(.*)$ http://www.mydomain.com/forum/threads/$1 permanent;
The challenge here is that you need the rewrite rules in root to send everything to /forum. But, doing so will also send all your wordpress urls there too. So, you need to be more specific and look for keywords, like 'thread' , 'resources', etc in the url and 301 those up to the new folder in order to allow wp urls to process at the root level.

you'll need to convert this style to nginx rules (i think that's what you're using per above) but this is the general concept....

in ROOT htacces,

RedirectMatch 301 ^/threads/(.*)$ https://www.yourdomain.com/forum/threads/$1
RedirectMatch 301 ^/members/(.*)$ https://www.yourdomain.com/forum/members/$1

etc for the major category of pages
 
In the wordpress root dictionary .htaccess is not working for ngix.

The ROOT .htaccess seems to only work for Apache.
 
Last edited:
correct, you'll need to convert the above to nginx config rules, as mentioned. htaccess is an apache thing.

i don't know what that is as i don't use nginx. so, apply that concept to nginx rules.
 
I am using these codes at this moment:
Code:
rewrite ^/resources/(.*)$ http://www.mydomain/forum/resources/ permanent;
rewrite ^/threads/(.*)$ http://www.mydomain/forum/threads/ permanent;

It works, but it redirects all url https://mydomain.com/resources/abc to https://mydomain.com/forum/resources without the end parameters

Tried in the codes added $:
Code:
rewrite ^/resources/(.*)$ http://www.mydomain.com/forum/resources/$ permanent;
rewrite ^/threads/(.*)$ http://www.mydomain.com/forum/threads/$ permanent;

But service shows the error below so it can not be saved in the settings:
1650502078741.png
 
Last edited:
If it was .htaccess / Apache, you would use:

$1 instead of just $ in the rewrite rule, so try:

Code:
rewrite ^/resources/(.*)$ http://www.mydomain.com/forum/resources/$1 permanent;
rewrite ^/threads/(.*)$ http://www.mydomain.com/forum/threads/$1 permanent;
 
Solution
@nocte Great, now it works perfectly. Thank you so much for looking at my problems.

@briansol Thank you so much for helping me with the Expressions, you told me ways that will work in Apache, but Nocte corrected my mistakes.
 
Back
Top Bottom