RESOLVED - HTACCESS Redirect viewforum and viewtopic to a directory

SHTFM
User w
User w
Posts: 12
Joined: Sat May 13, 2017 3:03 am

RESOLVED - HTACCESS Redirect viewforum and viewtopic to a directory

Post by SHTFM »

I used to have the forum in the ROOT
I now moved it to a folder example --> /phpbb
I want my old search terms viewforum?= AND viewtopic?=
to redirect to
/phpbb/viewforum?= AND /phpbb/viewtopic?=

From the ROOT htaccess but I do not want to mess up my wordpress which is in another folder but has an HTACCESS from root
SHTFM
User w
User w
Posts: 12
Joined: Sat May 13, 2017 3:03 am

Re: HTACCESS Redirect viewforum and viewtopic to a directory

Post by SHTFM »

Nevermind I figured it out

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^$ - [E=noabort:1]
# Redirect Forum
RewriteCond %{REQUEST_URI} !^/forums-directory/
RewriteRule ^view(.+)\.php$ /forums-directory/$0 [QSA,NC,L,R]
SHTFM
User w
User w
Posts: 12
Joined: Sat May 13, 2017 3:03 am

Re: HTACCESS Redirect viewforum and viewtopic to a directory

Post by SHTFM »

Please mark as [SOLVED]
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re-solved: HTACCESS Redirect viewforum and viewtopic to a directory

Post by axew3 »

Resolved but just the fixing code for all rewrite, and correct scrolls is coming ...
one have let me lost some time because was really not working in any way.
Finally i've take a not common js solution, guess some other will found a better way but in the while this work.
I mean a link rewrite like this:

Code: Select all

https://www.mysite.com/w3/forums/viewtopic.php?iframe=true&f=2&t=525&e=1&view=unread#unread
as on actual online code, the redirect is wrong. It redirect to the first page, even if the post contain more posts and the showed should be the latest one.
As on online here, the page is correct, but page not scroll to bottom.
SO after some fails, i've resolve with this coming tip:
on page forum, the function function w3all_ajaxup_from_phpbb(res){
should become something like this (This is PSEUDO code, that work)

Code: Select all

function w3all_ajaxup_from_phpbb(res){
	
			var w3all_phpbb_u_logged  = /#w3all_phpbb_u_logged=1/ig.exec(res);
			 if( res.indexOf('#w3all_phpbb_u_logged=') > -1 && w3all_phpbb_u_logged == null && null !== (document.getElementById('wp-admin-bar-my-account')) ){
        window.location.reload(true);
       }
			var w3all_phpbbpmcount = /.*(#w3all_phpbbpmcount)=([0-9]+).*/ig.exec(res);
      if(w3all_phpbbpmcount !== null){
         w3all_ajaxup_from_phpbb_do(w3all_phpbbpmcount[2]);
       }

   if(res.indexOf('#w3allScrollBottom') > -1) {
       setTimeout(w3Resizehs, 200); // delay to scroll
      function w3Resizehs(){
        var h = jQuery('iframe').contents().height();
             this.window.scrollTo(0, 3000);
		   }
		}
		      
} // END function w3all_ajaxup_from_phpbb(res){
and overall_footer.html change this piece of code that start immediately after

Code: Select all

if (window.frameElement) { // if in iframe mode ... to avoid js error w3all_ajaxup_from_phpbb is not a function when forum called not iframe mode (that you can also trascure maybe) if phpBB is surfed by full address and not iframe
//* // remove this line to activate
in this way, where the window location is send out to check on page-forum.php:

Code: Select all

var w3allGetLocation = window.location;
window.onload = function() {
var pmn = "{PRIVATE_MESSAGE_COUNT}";
var w3all_phpbb_u_logged = "{S_USER_LOGGED_IN}";
//
if (w3allGetLocation.indexOf('view=unread') > -1 == true){
 w3allScrollBottom = '#w3allScrollBottom';
} else { w3allScrollBottom = ''; }
// to send to wp at once here, like this: #w3all_phpbbpmcount=val#w3all_phpbbnotifycount=val#etc etc etc
var w3appendevents = '#w3all_phpbbpmcount=' + pmn + '#w3all_phpbb_u_logged=' + w3all_phpbb_u_logged + w3allScrollBottom;
parent.w3all_ajaxup_from_phpbb(w3appendevents);
}
this pseudo code to be finished scroll down page forum, to latest post, and with correct redirect all is perfect.
I guess someone know, how to get the size of iframe, and pass after it to scroll page forum, in different way?
setTimeout(w3Resizehs, 200); // delay to scroll, so the page and iframe has been loaded and page correctly scroll
this work fine ... but really can't exist another way?
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: RESOLVED - HTACCESS Redirect viewforum and viewtopic to a directory

Post by axew3 »

p.s the good solution should be i think:
put eyes on iframe resizer code, and let it send out all vars ... thing that i've still not consider to check if possible.
It send vars onclick ... why not on different event?
SHTFM
User w
User w
Posts: 12
Joined: Sat May 13, 2017 3:03 am

Re: RESOLVED - HTACCESS Redirect viewforum and viewtopic to a directory

Post by SHTFM »

Yes that would be good and would be GREAT if you could get the META Tags from the forum and parse them into the wordpress frame for SEO
Like my post here viewtopic.php?iframe=true&f=2&t=526
Post Reply