简体   繁体   English

使用htaccess重定向网站时出错

[英]Error with redirection of website with htaccess

I was trying to get rid of the index.html in my url. 我试图摆脱URL中的index.html。

.htaccess 的.htaccess

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://saturnstudios.org/$1 [R,L]

Everytime I load the website https://www.saturnstudios.org/index I get the error Error 404 - Not Found The document you are looking for may have been removed or re-named. 每次我加载网站https://www.saturnstudios.org/index时 ,都会出现错误错误404-找不到您正在查找的文档可能已被删除或重命名。 Please contact the web site owner for further assistance. 请与网站所有者联系以获取进一步的帮助。

Even though the documents are named right. 即使文件命名正确。

在此处输入图片说明

<h1 class="nav-link"><a href="index">Home</a></h1>
</li>
<li>
   <h1 class="nav-link"><a href="about">About</a></h1>
</li>
<li>
<h1 class="nav-link"><a href="contact">Contact</a></h1>

Any ideas of how to fix it? 关于如何解决的任何想法?

You can try to remove .html extension from url with this: 您可以尝试使用以下方法网址中删除.html扩展名

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [QSA,L]

Add it on the end. 最后添加。

Hope it helps. 希望能帮助到你。

You can just add MultiViews option to make it work by loading correct file after adding extensions internally. 您可以仅添加MultiViews选项,以在内部添加扩展名后加载正确的文件来使其工作。

Place this line at top of your .htacces: 将此行放在.htacces的顶部:

Options +MultiViews

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM