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?

4

4 回答 4

3

.htacces 中的类似内容应该这样做:

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

301 返回码将移动标记为永久,使浏览器可以更新书签。

于 2008-09-16T18:06:53.153 回答
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.

于 2008-09-16T18:02:02.027 回答
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]
于 2008-09-16T18:02:17.453 回答
0

您可以编写一个小的重定向脚本来简单快速地处理这个问题。

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

在根目录中的 index.php 中输入该内容作为唯一内容,然后发送到该文件夹​​的任何请求都会将用户重定向到论坛。

于 2008-09-16T18:04:56.637 回答