如何使网站应用程序出现在网站的根目录中?

时间:2021-05-29 11:18:14

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

我有一个公告牌(基于punBB),我在根目录中运行了几年。我愚蠢地决定做一点园艺,并在此过程中将punbb代码移动到它自己的子目录中。代码效果很好;只要您将浏览器指向新的子目录即可。问题是用户希望在根目录中看到它...

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.

但这似乎并没有成功。所以,我尝试在.htaccess中使用mod_rewrite的“该死的伏都教”,但我似乎无法找出正确的规则组合以使其工作。

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 个解决方案

#1


3  

Something like this in .htacces should do it:

.htacces中的这样的东西应该这样做:

    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.

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

#2


1  

a PHP file with a 301 HTTP permenant redirect.

具有301 HTTP永久重定向的PHP文件。

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

将以下内容放入guardthe.net根目录下的index.php中

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

browser will re-direct with search engine friendliness.

浏览器将与搜索引擎友好性重新指向。

#3


0  

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

您的示例代码丢失,但这是使用mod_rewrite执行此操作的一种方法:

RewriteEngine on
RewriteRule ^$ http://guardthe.net/punbb/ [L,R=301]

#4


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.

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

#1


3  

Something like this in .htacces should do it:

.htacces中的这样的东西应该这样做:

    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.

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

#2


1  

a PHP file with a 301 HTTP permenant redirect.

具有301 HTTP永久重定向的PHP文件。

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

将以下内容放入guardthe.net根目录下的index.php中

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

browser will re-direct with search engine friendliness.

浏览器将与搜索引擎友好性重新指向。

#3


0  

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

您的示例代码丢失,但这是使用mod_rewrite执行此操作的一种方法:

RewriteEngine on
RewriteRule ^$ http://guardthe.net/punbb/ [L,R=301]

#4


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.

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