【问题标题】:.htaccess file and clean Urls problem.htaccess 文件和清除 Urls 问题
【发布时间】:2011-05-24 04:29:57
【问题描述】:

我一直在使用相同的 .htaccess 文件来删除我网站中的 .php 扩展名。我似乎无法弄清楚这次什么不起作用。它是我注册的新托管服务提供商。我尝试对 SO 进行简单的重定向以查看文件是否被解析,它确实如此。我阅读了整本 Apache Mod_rewrite 书并了解该文件的作用,但我缺少一些东西。提前感谢您的帮助。这是文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteBase /
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.+) index.php [L]

顺便说一句,它在 public_html 文件夹中,应该没什么区别。

【问题讨论】:

  • 刚刚找到了我的问题的解决方案。我现在正在使用这个:
  • RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^index\ .php$ / [R=301,L]

标签: .htaccess mod-rewrite clean-urls


【解决方案1】:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteRule ^page-name\.html$ page-name.php [T=application/x-httpd-php,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-04
    • 1970-01-01
    • 2014-02-19
    • 2012-01-17
    • 1970-01-01
    • 2011-10-03
    相关资源
    最近更新 更多