.htaccess 重写以特定格式结尾的任何URL的规则
我想重定向所有以.htaccess 重写以特定格式结尾的任何URL的规则,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我想重定向所有以 data.html到templates/data.php info.html到templates/info.php any_other_file.html到templates/index.php 同样,所有以这些名称结尾的URL(可能是http://some-domain.com/some/long/path/data.html)您可以在/.htaccess文件中使用此选项: 重新编写引擎打开 #在内部将data/info.html重写为适用的PHP文件 #在模板目录中 重写规
data.html
到templates/data.php
info.html
到templates/info.php
any_other_file.html
到templates/index.php
同样,所有以这些名称结尾的URL(可能是
http://some-domain.com/some/long/path/data.html
)您可以在/.htaccess
文件中使用此选项:
重新编写引擎打开
#在内部将data/info.html重写为适用的PHP文件
#在模板目录中
重写规则(data | info).html$/templates/$1.php[NC,L]
#将以.html结尾的所有内容重写为/templates/index.php
重写规则^(.*).html$/templates/index.php[NC,L]
您尝试过什么?这真的很简单……我已经成功地将所有文件重定向到template/index.php
,使用以下规则:RewriteRule^(.*)$template/index.php[NC,L]
,但这就是我所能做的一切。这很好!请再说一件事:我如何让任何url进入templates/index.php?不仅仅是那些以.html结尾的;当然,除了data&info.html之外,我想我知道了,只是从最后一行删除了.html