【发布时间】:2014-08-29 14:20:04
【问题描述】:
我有一个子域作为一个全新的网站 (subdomain.domain.com = subdomain.com)。我主要使用 .html 文件,但想摆脱那些扩展名(而不是 http://subdomain.com/file.html,我想要 http://subdomain.com/file )。我已使用下面的 .htaccess 代码来完成此操作。
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L,QSA]
唯一的问题是,我还需要去掉网站上其他文件的 .php 扩展名。大多数人说用 .php 替换 .html 来复制上面的代码。我已经这样做了;不起作用。我已经尝试了许多其他版本的代码,但仍然无法正常工作。
由于我根本不是 .htaccess 方面的专家,谁能解释一下如何删除 .html 和 .php 文件扩展名? 提前致谢。
我不认为这是一个重复的问题,因为我还没有看到其他人问过如何一次替换多个文件扩展名。
【问题讨论】:
标签: regex apache .htaccess mod-rewrite url-rewriting