htaccess如何清除网址中的php和html

时间:2018-09-18 11:08:13

标签: php html .htaccess

我的网站有问题。我无法通过网址重写同时隐藏.html和.php。我可以使用.htaccess文件隐藏其中之一,但不能同时隐藏两者。 我试图将.php转换为.html,但是它不起作用。 我已经看到stackoverflow中有很多关于该主题的主题。而且我尝试了他们所说的所有内容,并且使我的网站中断了很多时间XD没什么用。 我也尝试过其他网站的解决方案,但也无济于事。

也许我错过了一些东西。也许我做错了我不知道的事情。也许我的网站是特定的。 这是我的网站:elisabethpluquetportfolio.com

您能帮我解决这个问题吗?我迷路了。

谢谢:)

编辑: 这是我实际的htaccess:

#reecriture des liens pour éviter de laisser apparaître .html dans l'url
RewriteEngine On
#Remove .html suffix
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html  [L]

# 301 permanent redirect all .html to non .html pour rediriger les liens 
dont on a enlevé le html
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

如果我对.php执行相同的代码,则将.html替换为.php则无效。这是行不通的,因为对于html和php,我无法两次获得此代码。

我也尝试过:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

它不起作用。

我也试图用html重命名php,但是它不起作用。 当它不起作用时,我的浏览器会告诉我找不到该页面。

我没有尝试过的所有代码,因为我做了很多尝试而没有保留任何记录。我应该这样做,尤其是为了避免多次尝试同一件事并向您展示我的工作。

0 个答案:

没有答案