HTACCESS - 将根文件夹设置为public_html

时间:2016-04-19 19:19:43

标签: php apache .htaccess

所以,我目前正在编写我的.htaccess文件,而且我偶然发现了根文件夹的问题。目前,http://localhost/public_html/index是我网站的根目录。我想做的是将网址改为http://localhost/index

我知道这很简单,但到目前为止我看过的所有帖子都没有证明有效。这是我到目前为止所产生的404错误。

RewriteEngine On

RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public_html/
RewriteRule ^(.*)$ /public_html/$1 [QSA]

如果可能,请包含.htaccess本身的任何文档或指南。 感谢。

1 个答案:

答案 0 :(得分:0)

可以添加以下.htaccess代码来实现所需的结果:

RewriteEngine on

RewriteCond %{REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]
相关问题