0

我的朋友最近告诉我,我能够做类似的事情

http://example.com/about/

无需创建目录并在其中放置 index.html,就像这样。

http://example.com/about/index.html

你到底是怎么做到的?除非您创建一个目录并在其中放置一个 index.html,否则我什至不知道这是否可行,无论如何,谢谢。:)

4

3 回答 3

0

如果您使用 Apache 作为 WEB 服务器,请使用 .htaccess 作为您的站点根目录。在这里写下以下规则:

目录索引 index.html

您也可以在这里使用多个文件:

DirectoryIndex index.php index.html

在这种情况下首先找到将被使用。

如果您不想使用 .htaccess,您可以在 Apache 配置文件 (httpd.conf) 中进行相同的设置:

<目录/foo>

DirectoryIndex index.html

DirectoryIndex index.php 

</目录>

这里 /foo - 您网站的根目录

于 2013-09-09T09:38:55.043 回答
0

如果您使用 Apache Web 服务器,则创建一个名为 .htaccess 的文件并编写如下代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?load=$1 [PT,L]

如果此代码在您键入 www.example.com/about 之类的 url 时打开您的 aboutController 在此 url 中写入 aabout http://salopek.eu/content/28/create-a-simple-php-mvc-framework

如果您不使用 Apache 或者您想要简单的解决方案,那么您可以创建一个名为 about 的文件夹并创建一个简单的 index.html 或 index.php 文件。然后,当您键入 www.example.com/about 时,它会打开您的 about\index.html 或 index.php 文件

我希望它有帮助

于 2013-09-09T09:51:26.820 回答
0

Nginx这样的服务器可以让你重写 URL,所以你可以把你的文件放在任何你想要的地方。

于 2013-09-09T09:35:17.750 回答