I would like to redirect all traffic from /phpBB3/* to /forum/*. Here's the .htaccess file I setup:
RewriteRule RewriteRule ^phpBB3/([.]+) forum/$1
That didn't work. I tried to mimic Drupal's syntax and came up with:
RewriteRule ^phpBB3/(.*)$ forum/$1
That didn't work either.

I would love to simply rename the phpBB3 folder (which lives at htdocs/ alongside Drupal's files) to "forum", but I can't get phpBB to work inside a frame without it using an alias ("forum" in my case) that points to the phpBB folder.

Any solutions? Is my RewriteRule even correct?

Thank you!!

Comments

cog.rusty’s picture

What do you have in the destination, in /forum, where you are redirecting? Does /forum work?

.kuma’s picture

Thank you for the reply!

The forums is accessible through a Drupal frame at /forums. In my htdocs folder, there is nothing named "forum". There's a folder called phpBB3 which contains the forum.

No, /forum doesn't work. Both forum and /forum produce an infinite frame-in-frame...

Thanks for any input!

cog.rusty’s picture

I am not sure that a .htaccess rewrite is the right way, because rewrites and redirects expect that the destination URL exists, and they just take you there.

The http://drupal.org/project/phpbbforum integration module creates a virtual drupal path for the forums.

.kuma’s picture

The URLs really do exist. When I browse the forums from within the Drupal frame and hover over a link, it points to the actual folder that lives at htdocs/phpBB3. I can copy and paste this link, but it doesn't retain the Drupal frame; it goes directly to the forums.

Maybe I was a little unclear before. I hope this better describes my problem:

The phpBB application lives at htdocs/phpBB3; Drupal lives at htdocs/

I installed the module that allows accessing phpBB from Drupal within a frame at mysite.com/phpbbforum.

I want users to be able to copy a link in the forums and paste it in an email for example, however the links all point to the stand-alone phpBB application. In other words, if a user copies a link while browsing the forums from Drupal, they copy mysite.com/phpBB3/viewfroum.php?f=11 for example. Then if they try to use this link, it will go directly to the forums site without being in the Drupal frame.

I tried to use the following RewriteRule:
RewriteRule ^phpBB3/(.*)$ phpbbforum/$1 [L,QSA]

but it puts another instance of the site (with no forums) inside the frame that usually contains the forum.

Here is Drupal's .htaccess RewriteRule:

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

I tried putting my RewriteRule before and after this rule; both resulted in the same behavior as mentioned above.

Please help! I'd really like to understand why this isn't working.

Thank you!

(I removed the forum aliases to simplify things. When I first installed phpBB3 I set aliases from forum to phpbbforum. I removed these to see if that would work, but it still doesn't. mystite/phpbbforum is the link which allows me to see the forums in a frame)

cog.rusty’s picture

I think that a RewriteRule A B will never let any content from A to be served. It will always change any request for A to a request for B, and this can go in circles.

.kuma’s picture

Thank you very much for your reply.

Isn't this what I want? I want the content at B to be served. Although I guess my situation differs in that content lives at both URLs.

If I browse the forums through the Drupal frame and right-click on a link and copy it, e.g. http://mysite.com/forum/viewforum.php?f=29, then paste this into my browser, I get the forum without frames. However, if I then manually change "forum" to "phpbbforum", the correct location opens up in the Drupal frame.

So is redirect impossible if content lives at "A"? Seems there's some solution since I can manually change the URL and it works.

Thanks for any help!!

.kuma’s picture

Anyone have any ideas?

aguspc1’s picture

perhaps you can try this... I hope this can help you.

Agus Pang (http://aguspc1.blogspot.com/)
Jakarta, Indonesia.

http://blog.taragana.com/index.php/archive/mod_rewrite-not-working-in-ht...

I faced a hair-tearing problem. mod_rewrite was loaded and yet it was not working in .htaccess files (and httpd.conf initially). Here is the solution along with how you can debug mod_rewrite problems.

Debugging procedure:
Add these two line to your httpd.conf immediately after RewriteEngine On.
RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 9
After that I added the required RewriteRule etc.

The reason for testing directly in httpd.conf is to ensure that mod_rewrite is working in the first place. After some debugging I realized my expression was wrong. So now I found mod_rewrite was working in httpd.conf. However it still wasn't working in .htaccess files.

Solution:
I found AllowOverride was set to None in httpd.conf. I changed it to All (after all I am the only user of the machine). And it finally started working everywhere (after a restart).

What I learnt:
Unmanaged dedicated web hosting is really really painful, unless you are (or have) a good linux system administrator. Too many things to setup and too many points of failure. And I haven't even started working on serious hardening stuff.

px’s picture

Looks like you are missing a RewriteCond to go with that RewriteRule. Try:
RewriteCond %{REQUEST_URI} ^/phpBB3/(.*)$ [NC]
RewriteRule ^(.*)$ forum/$1 [L,R=301]

(Don't call me out on that though. mod_rewrite is a nightmare)

yigis36865’s picture

A RewriteRule require url redirect generator, in my opinion, will never permit any content from A to be served. Every query for A will always be changed to a request for B, which might lead to endless loops.