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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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 Htaccess重写规则仅重定向主网站页面_.htaccess - Fatal编程技术网

.htaccess Htaccess重写规则仅重定向主网站页面

.htaccess Htaccess重写规则仅重定向主网站页面,.htaccess,.htaccess,我使用此规则将所有http请求重定向到https: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule (.*)index\.php$ /$1 [NS,R=301,L] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [

我使用此规则将所有http请求重定向到https:

 <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule (.*)index\.php$ /$1 [NS,R=301,L]

        RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

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

        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]

        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{SERVER_PORT} 80
        RewriteRule ^(.*)$ https://sitename.ro$1 [R,L]
    </IfModule>
我被重定向到https,但我得到404


这是由托管提供商造成的还是规则应该不同?

请在规则开头更改(https重写向上移动):


联系我的主机提供商,经过一些修改后,所有请求都被重定向到。 这是htaccess文件:

  #Reinnoire Let's Encrypt
    RewriteEngine On
    RewriteRule ^.well-known - [L]
    #Final Reinnoire Let's Encrypt

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
        <IfModule mod_headers.c>
            <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
            Header set Access-Control-Allow-Origin "*"
            </FilesMatch>
        </IfModule>
        RewriteEngine On
        RewriteBase /
        RewriteRule (.*)index\.php$ /$1 [NS,R=301,L]
        #RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
\reinoire让我们加密
重新启动发动机
重写规则^众所周知-[L]
#最后的雷诺瓦让我们加密
重新启动发动机
重写条件%{HTTPS}关闭
重写规则。*https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写cond%{HTTP_HOST}^www\。[北卡罗来纳州]
重写规则。*https://www.%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
选项-多视图
标题集访问控制允许原点“*”
重新启动发动机
重写基/
重写规则(.*)索引\.php$/$1[NS,R=301,L]
#重写条件%{HTTP_HOST}^www\.(.*)$[NC]
#重写规则^(.*)$http://%1/$1[R=301,L]
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}(+)/$
重写规则^1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
#句柄授权头
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
标题集缓存控制“最大年龄=31536000,公共”

我有两个相同的网站域名,对他们两个请求重定向到https

我已经改变了,但是现在我收到了404。索引文件也应该被更改吗?主页正在工作,但任何其他页面都接收404。这是一个Laravel应用程序。
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://sitename.ro%{REQUEST_URI} [L,R=301]
  #Reinnoire Let's Encrypt
    RewriteEngine On
    RewriteRule ^.well-known - [L]
    #Final Reinnoire Let's Encrypt

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
        <IfModule mod_headers.c>
            <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
            Header set Access-Control-Allow-Origin "*"
            </FilesMatch>
        </IfModule>
        RewriteEngine On
        RewriteBase /
        RewriteRule (.*)index\.php$ /$1 [NS,R=301,L]
        #RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>