.htaccess “我如何删除”;索引“;从我的网站链接

.htaccess “我如何删除”;索引“;从我的网站链接,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,因此,我一直在努力从我的网站url的末尾删除垃圾,并设法从我的所有链接中删除.html,但是在我的主页上,当从内部链接访问它时,我不能 我将目录索引设置为index.html,但是我必须链接回主页的任何href都会将/index保留在url中 # Sets website homepage DirectoryIndex index.html # mod_rewrite starts here RewriteEngine on # Make sure that existing directo

因此,我一直在努力从我的网站url的末尾删除垃圾,并设法从我的所有链接中删除.html,但是在我的主页上,当从内部链接访问它时,我不能

我将目录索引设置为index.html,但是我必须链接回主页的任何href都会将/index保留在url中

# Sets website homepage
DirectoryIndex index.html

# mod_rewrite starts here
RewriteEngine on

# Make sure that existing directories arent changed, and wont run RewriteRule
RewriteCond %{REQUEST_FILENAME} !-d

# Check for file in dir w/ .html extension
RewriteCond %{REQUEST_FILENAME}\.html -f


RewriteRule ^(.*)$ $1.html [NC,L]

我曾希望在我的主页被导航到的任何时候,url都会以
.com
而不是
.com/index
结尾。相反,只有在首次导航到网站时,url才会以
.com

结尾。请在.htaccess文件顶部检查此修改的规则

# Sets website homepage
DirectoryIndex index.html

# mod_rewrite starts here
RewriteEngine on

# Redirect index
RewriteRule ^index\.(php|html|htm)$ / [R=301,L]

# Make sure that existing directories arent changed, and wont run RewriteRule
RewriteCond %{REQUEST_FILENAME} !-d

# Check for file in dir w/ .html extension
RewriteCond %{REQUEST_FILENAME}\.html -f

RewriteRule ^(.*)$ $1.html [NC,L]