2012-12-23 59 views
0

我有5个使用相同编码模板的WordPress站点。该编码模板(我无法更改)使用一些基本的html布局代码调用名为“2012.orange.html”的文件。我在我的服务器的“/ home /”目录中创建了一个“my_template.php”,而在我的模板目录中的另一个“2012_orange.php”文件中,“/ home /”包含了“my_template.php”。使用.htaccess将.html重定向到.php

我的目标是用于“/ home /”目录中的“my_template.php”文件来控制5个不同站点的布局,但我无法弄清楚如何获取特定的.html文件文件来代替调用.php文件。

我做了我的“robots.txt”类似的东西使用下面的代码,它工作得很好:

# BEGIN - Robots Rewrite 
RewriteEngine on 
RewriteRule ^robots\.txt$ robots.php [L] 
## END - Robots Rewrite 

但我不能得到这个工作...我没有得到HTML布局:

# BEGIN - Template Rewrite 
RewriteEngine on 
RewriteRule ^2012\.orange\.html$ 2012_orange.php [L] 
## END - Template Rewrite 

再然后,将2012_orange.php将只包含以下内容包括:

<?php include ('/home/my_template.php'); ?> 

的当想要调用原始的.html文件时,如何让.htaccess重定向到文件的.php版本?

回答

1

.htaccess仅在HTTP请求中用于重定向url。脚本运行后,包括模板不会被.htaccess以任何方式包含,因为您包含的是文件,而不是网址。

1

你能从公用文件夹中输入2012_orange.php文件路径吗?

你的代码看起来,如果你有2012_orange.php文件的另一个文件夹里面做工精细的根目录2012_orange.php,

你必须改变像home/2012_orange.php

# BEGIN - Template Rewrite 
RewriteEngine on 
RewriteRule ^2012\.orange\.html$ home/2012_orange.php [L] 
## END - Template Rewrite 
路径