如何重写主页?

发布于 2024-10-19 18:51:08 字数 384 浏览 1 评论 0原文

如果文件夹中没有索引文件,我如何从另一个文件夹重写索引文件...例如主站点有两个像这样的文件夹,

main_folder/no index.php
folder1/index.php
folder2/index.php

我必须在重写规则中添加什么才能使主页显示索引folder1/index.php

编辑

让它与此一起工作

RewriteEngine On
RewriteCond %{HTTP_HOST} site.com
RewriteCond %{REQUEST_URI} !folder1/
RewriteRule ^(.*)$ folder1/$1 [L]

if there is no index file in the folder how do i rewrite an index file from another folder...so for example the main site has two folders like this

main_folder/no index.php
folder1/index.php
folder2/index.php

what do i have to put in the rewrite rule to make the main page show the index for folder1/index.php

EDIT

got it working with this

RewriteEngine On
RewriteCond %{HTTP_HOST} site.com
RewriteCond %{REQUEST_URI} !folder1/
RewriteRule ^(.*)$ folder1/$1 [L]

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

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

发布评论

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

评论(2

情深缘浅 2024-10-26 18:51:08

试试这个:

#in the .htaccess file where there is no exit or in root
Options Indexes #if still fails delete this line
DirectoryIndex /folder1/index.php

虽然编辑不确定

:对于子级别可能会添加这个解决方案。

RewriteCond %{REQUEST_URI} ^/folder1/
RewriteRule ^(.*)$ http://www.example.org/$1 [L]

Try this:

#in the .htaccess file where there is no exit or in root
Options Indexes #if still fails delete this line
DirectoryIndex /folder1/index.php

Not sure though

edit: for sub levels maybe adding this solves.

RewriteCond %{REQUEST_URI} ^/folder1/
RewriteRule ^(.*)$ http://www.example.org/$1 [L]
痞味浪人 2024-10-26 18:51:08

你只想要一个重定向吗?

Redirect 301 / /folder1/index.php

do you just want a redirect?

Redirect 301 / /folder1/index.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文