2013-02-27 96 views
0

我想重写PHP文件为.xml目录rss/index.php文件及其子目录rss/all/index.phprss/main/index.phpsub directories而已,我不想影响其他来.XML使用此规则的网站中的目录。国防部重写.PHP在目录及其子目录只

root/rss/index.php to root/rss/index.xml 

root/rss/all/index.php to root/rss/all/index.xml 

我不知道国防部重写了,我想这种方式,但它什么都不做。

RewriteRule ^/rss/.xml$  $1.php [L] 
also tried like this 
RewriteRule ^(rss).xml$  $1.php [L] 

请参阅并建议任何可能的方法来做到这一点。

谢谢。

回答

1

尝试:

RewriteRule ^/?Site/rss/(.*)\.xml$ /Site/rss/$1.php [L] 

这将使它所以当有人请求/rss/something.xml,他们将获得服务无论是在/rss/something.php。这些规则必须位于文档根目录中的htaccess文件中。

+0

我得到404页面没有找到错误这种方式,页面url http:// localhost/Site/rss/index.xml' – 2013-02-27 08:09:44

+0

@TallboY在你的问题,你要求'root/rss/all/index .php到root/rss/all/index.xml',你确定你不是指相反的? – 2013-02-27 08:12:05

+0

我想重写index.php到rss /和rss/sub-directories /中的index.xml,就像你说的/rss/something.xml一样,它们会被送到/rss/something.php – 2013-02-27 08:23:52