无法从网站页面网址中删除.html扩展名

时间:2016-12-22 14:15:10

标签: html .htaccess

尽量简明扼要。 我已阅读帖子和页面,建议我可以通过更改.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

萨姆

1 个答案:

答案 0 :(得分:0)

尝试在 MSIHANDLE MsiHandle; MSIHANDLE ViewHandle=(MSIHANDLE)NULL; MsiOpenDatabase(MsiFullPath,MSIDBOPEN_TRANSACT,&MsiHandle); // This Will Update The Value Of Session To 70 But It Is A String Value (No Longer An Integer / REG_DWORD). // The Value Ends Up In The registry Table A '70' (No #). //MsiDatabaseOpenView(MsiHandle,L"UPDATE Registry SET Registry.Value=70 WHERE (Registry.Name='Session'),&ViewHandle); // https://msdn.microsoft.com/en-us/library/windows/desktop/aa371168(v=vs.85).aspx // Says: # The value is interpreted and stored as an integer (REG_DWORD). // Msi Does Not Like The #. This Returns ERROR_BAD_QUERY_SYNTAX MsiDatabaseOpenView(MsiHandle,L"UPDATE Registry SET Registry.Value=#70 WHERE (Registry.Name='Session'),&ViewHandle); MsiViewExecute(ViewHandle,(MSIHANDLE)NULL)

中使用此功能
.htaccess

这应从您的网址中删除RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html 。在测试之前,请确保清除缓存