我目前有一個靜態的HTML文件託管在我的Wordpress安裝的根文件夾中。我可以訪問網址http://example.com/er_trends_download
但當斜線被添加到URL得到一個內部服務器錯誤:http://example.com/er_trends_download/
htacess重定向到Wordpress根目錄下的靜態HTML
我已經加入線到.htaccess
文件從我的靜態文件,並在WordPress我永久的設置下降的.html
也設置爲刪除結尾的斜槓。我沒有保留斜線的偏好,我只是不想讓內部服務器錯誤,無論它是否是URL的一部分。我包括我的全.htaccess
文件如下:
# Use PHP5.6 as default
AddHandler application/x-httpd-php56 .php
php_value memory_limit 512M
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule^/%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule^%{REQUEST_URI}.html [NC,L]
</IfModule>
# 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>
# END WordPress
謝謝!這樣做的訣竅,我只需將您的代碼建議中的.php更改爲.html 如果您可以在響應中進行此編輯,我會將其標記爲已接受。 – SRouse
不客氣。對不起,是的,'.php'是習慣的力量(現在已更新)! – MrWhite