【发布时间】:2018-02-09 11:27:53
【问题描述】:
我目前在我的 Wordpress 安装的根文件夹中托管了一个静态 HTML 文件。我可以访问 URL http://example.com/er_trends_download,但在 URL 添加尾部斜杠时出现内部服务器错误:http://example.com/er_trends_download/
我在.htaccess 文件中添加了几行以从我的静态文件中删除.html,并且我在WordPress 中的永久链接设置也设置为删除尾部斜杠。我对是否保留斜杠没有偏好,我只是不想得到内部服务器错误,无论它是否是 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
【问题讨论】:
标签: wordpress .htaccess redirect mod-rewrite url-rewriting