通过的.htaccess以.html替换的.php分机 [英] replacing .php ext with .html through .htaccess
问题描述
您好!
我试图取代的.php与HTML扩展
到目前为止,我有:
重写规则^(。*)\。HTML $ 1.PHP
...它工作得很好,当URL如 /site/page.html
输入(和 page.html即可
物理上不存在,但 page.php
一样)。
不过我想有是当 /site/page.php
进入观众只看到 /site/page.html
在浏览器中的位置。
是可行的还是我必须设置明确的重定向每一页? : - (
在此先感谢。
PS:我使用的开发环境是XAMPP在OS X上,如果这有什么差别
重写规则^(。*)\。PHP $ 1.HTML [R = 301,L]
重写规则^(。*)\。HTML $ 1.PHP
拉着小白兔的帽子后修改
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} THE_REQUEST(。*)\。PHP
重写规则^(。*)\。PHP $ 1.HTML [R = 301,L]
的RewriteCond%{} THE_REQUEST(。*)\。HTML
重写规则^(。*)\。HTML $ 1.PHP [L]
Greetings!
I'm trying to replace .php extensions with .html
So far I got:
RewriteRule ^(.*)\.html $1.php
... it works nicely when url like /site/page.html
is entered (and page.html
does not physically exist but page.php
does).
However what I'd like to have is when /site/page.php
is entered the viewer sees only /site/page.html
in the browser location.
Is that doable or do I have to set up explicit redirects for each page? :-(
Thanks in advance.
ps: dev environment I'm using is XAMPP on os x if it makes any difference
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteRule ^(.*)\.html $1.php
edit after pulling white rabbit out of the hat
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]
这篇关于通过的.htaccess以.html替换的.php分机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!