.htaccess从URL中删除index.php和子文件夹

时间:2013-06-23 13:11:54

标签: .htaccess expressionengine

我是一名.htaccess新手,在从我的网站网址中删除文件夹名称方面遇到了问题。

目前:www.mydomain.com/engine

我在hosts html文件夹的子文件夹(命名引擎)中有一个表达式引擎站点。在这个文件夹中我有一个htaccess文件,其中我按照表达式用户指南中的说明删除了index.php?从URL成功,使用:

        RewriteEngine On

    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

我现在想要从URL中删除引用子文件夹的“引擎”。

我在之前的问题中已经多次尝试过建议,但没有成功。

在观看www.mydomain.com时,我接受了任何尝试:

禁止。您无权访问此服务器上的/。

我认为这可能是一个权限问题,但是这个包含html文件夹的权限与允许访问的“engine”文件夹具有相同的权限。

任何人都可以帮助我需要的.htaccess代码吗?

1 个答案:

答案 0 :(得分:0)

是的,以上规则不适用于主页网址,因为它是一个目录(不通过第三个RewriteCond),请使用以下代码:

    RewriteEngine On
    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d [OR]
    RewriteCond $1 ^$
    RewriteRule ^(.*)$ /engine/index.php?/ [L]
相关问题