Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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

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
Apache 仅当文件存在且是GET请求时重写_Apache_.htaccess - Fatal编程技术网

Apache 仅当文件存在且是GET请求时重写

Apache 仅当文件存在且是GET请求时重写,apache,.htaccess,Apache,.htaccess,我正在开发一个PHPCMS,目前正在实现一个静态文件缓存。缓存背后的思想是,所有页面都被编译成html,然后由apache或nginx提供服务。问题是,如果它不是GET请求,它仍然应该被重写到PHPCMS,而不是直接提供服务。这是我当前的htaccess配置,我删除了HTTPS重定向 <IfModule mod_rewrite.c> RewriteEngine On # If the requested filename exists, simply serve i

我正在开发一个PHPCMS,目前正在实现一个静态文件缓存。缓存背后的思想是,所有页面都被编译成html,然后由apache或nginx提供服务。问题是,如果它不是GET请求,它仍然应该被重写到PHPCMS,而不是直接提供服务。这是我当前的htaccess配置,我删除了HTTPS重定向

<IfModule mod_rewrite.c>
    RewriteEngine On

    # If the requested filename exists, simply serve it, but only if it is a GET request
    # We only want to let Apache serve files and not directories.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_METHOD} =GET
    RewriteRule ^ - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>

有人能帮我找出问题所在吗?

您的上一条规则创建了一个无限重写循环

解决方法:不要对基本索引应用规则

RewriteCond %{REQUEST_URI} !/index\.php$ [NC]
RewriteRule ^ %{ENV:BASE}/index.php [L]

除了
GET
RewriteCond %{REQUEST_URI} !/index\.php$ [NC]
RewriteRule ^ %{ENV:BASE}/index.php [L]