0

I have a bulletin board (punBB based) that I was running out of the root directory for a couple of years. I foolishly decided to do a little gardening and in the process moved the punbb code into it's own subdirectory. The code works great; as long as you point the browser at the new subdirectory. The issue is that the users expect to see it at the root...

I tried an index file in the root that had the following:

<?php chdir('punbb');
include('index.php');

But that didn't seem to do the trick. So, I tried using the "damn cool voodoo" of mod_rewrite in .htaccess but I can't seem to figure out the right combination of rules to make it work.

Here is what I would like to make happen:

User enters:

 http://guardthe.net

Browser displays:

 http://guardthe.net/punbb/ 

or

 http://punbb.guardthe.net/

Is this possible, or should I just move the code base back into the root?

DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119

4 Answers4

3

Something like this in .htacces should do it:

    RewriteEngine On
    RewriteRule ^/?$ /punbb/ [R=301,L]

The 301 return code is to mark the move as permanentm making it posible for the browser to update bookmarks.

Mr Shark
  • 26,068
  • 5
  • 29
  • 37
1

a PHP file with a 301 HTTP permenant redirect.

Put the following into index.php in the root directory of guardthe.net

<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://guardthe.net/punbb/" );
?>

browser will re-direct with search engine friendliness.

user13270
  • 29
  • 1
  • Unless there is no mod_rewrite support on your server, you should avoid this approach as the user must download this web page and have the browser display it before executing a second transaction back to the server. The delay is usually long enough for the user to notice. Go for mod_rewrite if poss. – Cheekysoft Sep 16 '08 at 18:32
0

Your example code is missing but here's one way to do it using mod_rewrite:

RewriteEngine on
RewriteRule ^$ http://guardthe.net/punbb/ [L,R=301]
Jan Krüger
  • 17,870
  • 3
  • 59
  • 51
0

You could write a small redirect script to take care of this simply and quickly.

<?php 
header( 'Location: http://guardthe.net/punbb/' ); 
?>

Enter that as the only content in your index.php in your root directory, and any requests sent to that folder will then redirect the user to the forum.

toluju
  • 4,097
  • 2
  • 23
  • 27