Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 未为live server上的项目编写我的htaccess规则(htaccess位于文件夹内)_.htaccess_Mod Rewrite_Url Rewriting_Friendly Url - Fatal编程技术网

.htaccess 未为live server上的项目编写我的htaccess规则(htaccess位于文件夹内)

.htaccess 未为live server上的项目编写我的htaccess规则(htaccess位于文件夹内),.htaccess,mod-rewrite,url-rewriting,friendly-url,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,我想做的是: 在特定项目的服务器上,我希望通过htaccess(从URL中删除.php或.html扩展名)编写URL重写规则 我的网站网址: 以及: 现在,如果您查看第二个URL.php扩展名,它将被完全删除,但当页面存在时,它会显示未找到页面 如果我在那里写: 它开始工作了 我试图在.htaccess中写入的内容(此文件在我的文件夹中): 弗斯特 重新启动发动机 重写基/EpcGroup/ 重写规则^index\.php$-[L] 重写cond%{REQUEST_FILENAME}-F

我想做的是:

在特定项目的服务器上,我希望通过htaccess(从URL中删除.php或.html扩展名)编写URL重写规则

我的网站网址:

以及:

现在,如果您查看第二个URL.php扩展名,它将被完全删除,但当页面存在时,它会显示
未找到页面

如果我在那里写:

它开始工作了

我试图在.htaccess中写入的内容(此文件在我的文件夹中):

弗斯特

重新启动发动机
重写基/EpcGroup/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([^\.]+)$$1.php[NC,L]
重写规则^([^\.]+)$$1.html[NC,L]
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$admin/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
第二:添加(EpcGroup/):

重新启动发动机
重写基/EpcGroup/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([^\.]+)$$1.php[NC,L]
重写规则^([^\.]+)$$1.html[NC,L]
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$EpcGroup/admin/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$EpcGroup/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$EpcGroup/index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404 EpcGroup/index.php
但它不起作用

一个.htaccess,在我的根目录上有以下代码:

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

根据最近的评论,将root
.htaccess
更新为:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/EpcGroup [NC]    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

这是给你的,我得到的。@Virb我正在检查并尝试,但到目前为止没有成功。我将更新一个在我的所有问题上不断投票给我的人,但不起作用:-(未找到页面)。根htaccess代码:-和内部htaccess:@Anant您的wordpress仍在控制您的其他路由。我不知道如何禁止WP这样做。根htaccess中的更改应该已经完成了。
现在我想:-RewriteBase上的RewriteEngine/RewriteCond%{REQUEST_URI}^/EpcGroup[NC]
仅此而已?即使过度写入,也无法正常工作。现在,我的根htaccess代码是:-
# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/EpcGroup [NC]    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /EpcGroup/

    RewriteRule ^index\.php$ - [L]

    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^[^\.]+$ $0.php [NC,L]

    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^[^\.]+$ $0.html [NC,L]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ admin/index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin
    ErrorDocument 404 /index.php
</IfModule>