【发布时间】:2017-05-08 04:45:54
【问题描述】:
会尽量简洁。 我已经阅读了建议我可以通过更改 .htaccess 文件将 .html 从 domain.com/page.html 删除到 domain.com/page 的帖子和页面。
建议我将此代码粘贴到文件中(我是通过 Bluehost 的编辑器完成的
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]
我使用 bluehost 托管,直到现在都使用过 wordpress 网站。 我正在使用我自己的 html 页面和样式表等创建我的第一个网站。
因此,.htaccess 文件中有很多其他信息:
# Use PHP5.4 as default
# Changed PHP handler from application/x-httpd-php54 to application/x-httpd-phpbeta on Mon Dec 14 19:23:46 MST 2015.
AddHandler application/x-httpd-phpbeta .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wp-content/endurance-page-cache/ - [L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 weeks"
</IfModule>
<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
所以我只是在结尾处粘贴了重写行。 该文件位于 public_html 文件夹中。然后,我的所有网站都有多个文件夹。
那么我做错了什么为什么这不起作用?我已经检查过 Bluehost,我使用的是 Apache 服务器
非常感谢您的帮助!
编辑:
尝试按照.htaccess 文件末尾的建议添加此内容:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
剩下的就是这个:
https://i.stack.imgur.com/qv0GJ.png
山姆
【问题讨论】: