Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 HttAccess获取从重写规则中排除的文件夹的https_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

.htaccess HttAccess获取从重写规则中排除的文件夹的https

.htaccess HttAccess获取从重写规则中排除的文件夹的https,.htaccess,redirect,mod-rewrite,.htaccess,Redirect,Mod Rewrite,我使用的是Laravel,所以我有重写规则重定向到index.php,我有规则重定向到www和https 我不希望URI/blog被重定向到index.php,但我需要它如下所示: 实际上它重定向到: example.com/blog 因为这条规则需要重写1美元^博客将其排除在重写规则之外 这是我的规则: <IfModule mod_rewrite.c> RewriteBase / <IfModule mod_negotiation.c> Options -Mu

我使用的是Laravel,所以我有重写规则重定向到index.php,我有规则重定向到www和https

我不希望URI/blog被重定向到index.php,但我需要它如下所示:

实际上它重定向到:

example.com/blog
因为这条规则需要重写1美元^博客将其排除在重写规则之外

这是我的规则:

<IfModule mod_rewrite.c>
RewriteBase /
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteCond $1 !^(blog) #I need this to get www and https but not further rules

# To https
RewriteCond %{REQUEST_SCHEME} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# To www if is not a subdomain
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
如果希望从index.php rewrite中跳过blog/,请将最后一条规则更改为:

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^blog(/.*)?$ index.php [L,NC]

我想是的,但那个URL是Wordpress博客。最初我没有重定向,我仍然离开example.com/blog,没有https或www。我配置了WP htaccess,现在它可以工作了。一开始,如果我没有放入RewriteCond$1,它会给我一个500错误博客,现在我删除了它和你的输入,它工作了。我不知道为什么,但我不抱怨。很高兴知道这有帮助,