0
当我在浏览器中输入一个URL地址的形式https://myurl.com/path吧,我想重写为https://myurl.com/path/为什么我的网址没有用结尾斜杠重写?
在.htaccess,我重写规则如下:
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^myurl.com$
#RewriteRule ^(.*)$ http://myurl.com/$1 [R=301,L]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://myurl.com/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://myurl.com%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
感谢@MrMr工作:)我没有亲自将规则添加到此.htaccess文件中,别人也这么做,所以我不能因为接近解决方案而承担功劳..我不确定为什么.html规则已添加,所有页面的格式为https:// myurl/path/page /。您是否建议我更换以下行: 'RewriteCond%{REQUEST_FILENAME} .html -f'和 'RewriteRule!。*。html $%{REQUEST_FILENAME} .html [L]'只有? – Mattypants
我现在遇到的一个问题是我的XML站点地图现在正在得到一个尾部斜线,即/sitemap.xml/。有趣的是 - 谢天谢地 - pdf文件没有得到一个斜线。 – Mattypants