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