<p>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...</p>

<p>I tried an index file in the root that had the following:</p>

<pre><code>&lt;?php chdir('punbb');
include('index.php');
</code></pre>

<p>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.</p>

<p>Here is what I would like to make happen:</p>

<p>User enters: </p>

<pre><code> http://guardthe.net
</code></pre>

<p>Browser displays: </p>

<pre><code> http://guardthe.net/punbb/ 
</code></pre>

<p>or</p>

<pre><code> http://punbb.guardthe.net/
</code></pre>

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

[{'answer_id': 75144, 'author': 'user13270', 'author_id': 13270, 'author_profile': 'https://Stackoverflow.com/users/13270', 'pm_score': 1, 'selected': False, 'text': '<p>a PHP file with a 301 HTTP permenant redirect.</p>\n\n<p>Put the following into index.php in the root directory of guardthe.net</p>\n\n<pre><code>&lt;?php\nHeader( "HTTP/1.1 301 Moved Permanently" );\nHeader( "Location: http://guardthe.net/punbb/" );\n?&gt;\n</code></pre>\n\n<p>browser will re-direct with search engine friendliness.</p>\n'}, {'answer_id': 75147, 'author': 'Jan Krüger', 'author_id': 12471, 'author_profile': 'https://Stackoverflow.com/users/12471', 'pm_score': 0, 'selected': False, 'text': "<p>Your example code is missing but here's one way to do it using mod_rewrite:</p>\n\n<pre><code>RewriteEngine on\nRewriteRule ^$ http://guardthe.net/punbb/ [L,R=301]\n</code></pre>\n"}, {'answer_id': 75185, 'author': 'toluju', 'author_id': 12457, 'author_profile': 'https://Stackoverflow.com/users/12457', 'pm_score': 0, 'selected': False, 'text': "<p>You could write a small redirect script to take care of this simply and quickly.</p>\n\n<pre><code>&lt;?php \nheader( 'Location: http://guardthe.net/punbb/' ); \n?&gt;\n</code></pre>\n\n<p>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.</p>\n"}, {'answer_id': 75214, 'author': 'Mr Shark', 'author_id': 6093, 'author_profile': 'https://Stackoverflow.com/users/6093', 'pm_score': 2, 'selected': False, 'text': '<p>Something like this in .htacces should do it:</p>\n\n<pre><code>    RewriteEngine On\n    RewriteRule ^/?$ /punbb/ [R=301,L]\n</code></pre>\n\n<p>The 301 return code is to mark the move as permanentm making it posible for the browser to update bookmarks.</p>\n'}]
['https://Stackoverflow.com/questions/75127', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']