【问题标题】:hide filename in url在url中隐藏文件名
【发布时间】:2013-01-24 11:08:20
【问题描述】:

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

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

【问题讨论】:

  • 没有足够的细节。什么不工作?

标签: php html .htaccess


【解决方案1】:

你可以使用它。这里我给出了静态代码。例如,我的文件名为 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]

【讨论】:

    猜你喜欢
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 2020-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多