301通过.htaccess重定向的域名后缀第二个斜杠

时间:2018-09-11 10:08:42

标签: .htaccess redirect http-status-code-301

当301将带有斜杠的URL重定向到非斜杠的URL时,我遇到一种奇怪的行为。以下是我的httpd-app.conf文件(通过AWS上的Bitnami进行的WP)。

一切正常,例如IP已正确重定向到域名,默认情况下,URL不显示斜杠。但是,当我输入带有斜杠的URL时,它的确删除了URL末尾的斜杠,但将其添加到了另一个位置。像这样:

https://www.example.com/page/(之前) https://www.example.com//page(之后)

是否注意到域名后的第二个斜杠?这种情况如何发生以及如何预防?

RewriteEngine On
RewriteRule /<none> / [L,R]
RewriteCond %{HTTP_HOST} ^00\.000\.000\.00
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)/$ /$1 [L,R=301]

<IfDefine USE_PHP_FPM>
    <Proxy "unix:/opt/bitnami/php/var/run/wordpress.sock|fcgi://wordpress-fpm" timeout=300>
    </Proxy>
</IfDefine>

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options +MultiViews +FollowSymLinks
    AllowOverride None
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>



    <IfDefine USE_PHP_FPM>
       <FilesMatch \.php$>
         SetHandler "proxy:fcgi://wordpress-fpm"
       </FilesMatch>
    </IfDefine>


    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [S=1]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]

  Include "/opt/bitnami/apps/wordpress/conf/banner.conf"
</Directory>

Include "/opt/bitnami/apps/wordpress/conf/htaccess.conf"

0 个答案:

没有答案