需要修复localhost子目录上由.htaccess引起的过多重定向

时间:2018-08-25 03:49:45

标签: .htaccess

在Web服务器上工作的.htaccess代码。

    RewriteOptions inherit
    Options +FollowSymLinks
    Options -Indexes
    RewriteEngine on
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.domain1111.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

    RewriteCond %{HTTP_REFERER} !^https://domain1111.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^https://domain1111.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^https://www.domain1111.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^https://www.domain1111.com$      [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ https://domain1111.com [R,NC]

但是在本地主机上怎么了?

我在localhost上使用的代码是:

    RewriteOptions inherit
    Options +FollowSymLinks
    Options -Indexes
    RewriteEngine on
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ http://localhost/work2018.oct/directory/$1 [R=302,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

    RewriteCond %{HTTP_REFERER} !^http://localhost/work2018.oct/directory/.*$       [NC]
    RewriteCond %{HTTP_REFERER} !^http://localhost/work2018.oct/directory$          [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://localhost/work2018.oct/directory [R,NC]

0 个答案:

没有答案