.htaccess redirect from subfolder to root

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
joey09
Registered User
Posts: 2
Joined: Fri Jan 19, 2018 11:16 am

.htaccess redirect from subfolder to root

Post by joey09 » Fri Jan 19, 2018 11:26 am

Hi guys,

I've been working on this problem for a whole day now, searching pretty much everything that might be helpful, but I just can't find a solution.
I maintain a forum which is in two subdirectories of the website. The site itself runs with WordPress and the forum has always been installed two levels deep. So:
http://oldsite.com/folder/forum

Now the domain has to be changed and the forum has to be on a level above, so:
https://newsite.com/forum

That's working so far. I changed the script_path in the database and all that works just fine. The problem is the .htaccess redirect. I searched and tested as much as possible but it just won't work.

I tried these rules that were also working just fine on an .htaccess-testsite.

Code: Select all

RewriteEngine On 
RewriteRule ^folder/forum/index.php?(.*)$ forum/index.php?$1 [R=301,L]
RewriteRule ^folder/forum/viewforum.php(.*)$ forum/viewforum.php$1 [R=301,L]
RewriteRule ^folder/forum/viewtopic.php(.*)$ forum/viewtopic.php$1 [R=301,L]
RewriteRule ^folder/forum/memberlist.php?(.*)$ forum/memberlist.php?$1 [R=301,L]
But no matter which browser (of course with empty cache and / or private mode) I use, it doesn't work. I used these rules as well in the root .htaccess of the server as well as in the forums .htaccess but nothing works. (It would be correct to put them into the root of the server no?)
The following though weirdly works all the time: if I type https://newsite.com/folder/forum I am always redirected to https://newsite.com/forum. No matter what I type instead of "folder", it always redirects me to the correct URL even if nothing is set in both .htaccess files. Why is that the case and how can I get the other redirects to work?

Thanks a lot in advance,
Joey

joey09
Registered User
Posts: 2
Joined: Fri Jan 19, 2018 11:16 am

Re: .htaccess redirect from subfolder to root

Post by joey09 » Fri Jan 19, 2018 2:53 pm

Hi again,

seems that the mistake was on my side. I put all the new rules below the standard WordPress .htaccess rules. Now I put them on top of them, purged the cache and it seems to work correctly.
Maybe an amateur mistake but if someone else has that problem, that should help.

Best regards,
Joey

Post Reply

Return to “[3.2.x] Support Forum”

Who is online

Users browsing this forum: 22288DLW, Baidu [Spider], Brian Lambert, HayanTokki, madelharri and 59 guests