.htaccess 将特定文件转发到子文件夹

发布于 2025-01-06 19:56:36 字数 269 浏览 4 评论 0原文

我正在清理根目录,里面有很多“垃圾”。

所以我现在正在将所有文件移动到子文件夹“oldroot”中

,我的一些用户正在使用一些垃圾文件....但只有 3-4 个文件....是否有一种简单快捷的方法来配置 . htaccess 仅转发这些特定文件,例如

mypage1.php ==> oldroot/mypage1.php
mypage2.php ==> oldroot/mypage2.php

I am cleaning up my root directory, and it has a lot of "trash" inside.

so i am moving all the files so a subfolder "oldroot"

now, some of my users are using some of the trash files....but only 3-4 files....is there an easy and quick way to configure .htaccess to forward these specific files only, like

mypage1.php ==> oldroot/mypage1.php
mypage2.php ==> oldroot/mypage2.php

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仲春光 2025-01-13 19:56:37

在您的 .htaccess 文件 中使用:

RewriteEngine On
RewriteBase   /
RewriteRule   ^(mypage1|mypage2|mypage3)\.php$    oldroot/$1.php    [L]

In your .htaccess file use:

RewriteEngine On
RewriteBase   /
RewriteRule   ^(mypage1|mypage2|mypage3)\.php$    oldroot/$1.php    [L]
安稳善良 2025-01-13 19:56:37

尝试将以下内容添加到站点根目录中的 .htaccess 文件中。

它适用于您移动到oldroot 的任何文件,即您想要保留在根目录中的所有文件都将从那里提供服务。

RewriteEngine on
RewriteBase / 

#if the file exists in the oldroot directory
RewriteCond %{DOCUMENT_ROOT}/oldroot%{REQUEST_URI} -f [NC]
# then serve the file from oldroot
RewriteRule ^ /oldroot%{REQUEST_URI} [L]     

Try adding the following to the .htaccess file in the root directory of your site.

It will work for any file that you move to oldroot i.e. all of the files that you want to leave in the root will be served from there.

RewriteEngine on
RewriteBase / 

#if the file exists in the oldroot directory
RewriteCond %{DOCUMENT_ROOT}/oldroot%{REQUEST_URI} -f [NC]
# then serve the file from oldroot
RewriteRule ^ /oldroot%{REQUEST_URI} [L]     
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文