【发布时间】:2013-05-02 17:33:40
【问题描述】:
我正在尝试重写我的网址,但仍然没有成功。我用谷歌搜索了两天,但没有成功。我正在粘贴我的 .htaccess 代码
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} localhost [NC]
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteRule ^(.*)$ /folder1/$1 [L]
这是我的目录:
localhost/project/index.php
在这个页面中有两个按钮。如果单击按钮一个,它应该重定向到 folder1/index.php 否则如果单击两个按钮,那么它应该重定向 folder2/index.php
localhost/project/folder1/index.php
localhost/project/folder2/index.php
Basically I don't want display folder1 or folder2 directory names.
any idea please thanks
我要显示的实际网址应如下所示:
本地主机/项目/
【问题讨论】:
-
您需要告诉我们您希望每个文件夹显示为哪个 URL。您需要以某种方式区分这两个文件夹。
-
我想显示的实际网址应该如下所示:localhost/project/
-
好的,文件名呢? localhost/project/folder1 和 localhost/project/folder2 还是什么?你不能让 localhost/project 引用两个不同的位置。
-
您可以在点击时设置 cookie (folder1||folder2)。让 /project/index.php 检查 cookie 和 include('folderX/index.php'); :shrug: 祝你好运
-
@DavidHoude 我已经为此使用了 cookie,但我想要 url 重写并且不想显示 (folder1|folder2)。但它应该访问 (folder1/index.php|folder2/index.php) 但 url 应该是这样的:localhost/project/index.php