在我的网站网址末尾隐藏.html

问题描述 投票:0回答:1

我曾尝试用.htaccess文件中的此代码删除URL末尾的.html,但它仍然表示我在加载其他页面时缺少该文件。

# mod_rewrite starts here

RewriteEngine on

# does not apply to existing directories, meaning if the folder exists on the server then don't change anything and don't run the Rule!

RewriteCond %{REQUEST_FILENAME} !-d

# Check for file in directory with .html extension

RewriteCond %{REQUEST_FILENAME}\.html -f

# Here we actually show the page that has the .html extension

RewriteRule ^(.*)$ $1.html [NC,L]s
java html css .htaccess
1个回答
1
投票

只需将其命名为index.html,然后创建文件夹并在其中创建索引。

因此,例如,如果您要website.com/home,请在public_html内创建一个文件夹,并将其命名为home,然后对该文件进行索引。

© www.soinside.com 2019 - 2024. All rights reserved.