0

我尝试使用 .htaccess 文件中的以下代码将文件名隐藏在 URL 中。但是正在显示文件名。任何人都可以更正此代码。

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

1 回答 1

0

你可以使用这个。这里我给出了静态代码。例如,我的文件名为 testimonial.php,我将其更改为 testimonial.html。所以在一个标签链接中你应该给出 testimonial.html 而不是 testimonial.php。然后它会正常工作。

Options -Indexes
RewriteEngine on

RewriteRule ^testimonial.html /testimonial.php [NC]
RewriteRule ^aboutus.html /about_us.php [NC]
于 2013-01-24T11:48:27.503 回答