如何重写.html网址。 php文件使用.htaccess? [英] How to rewrite .html url to. php file using .htaccess?
问题描述
我已将网站从.html扩展名更改为.php;文件名相同,有数千个文件。现在有PHP代码无法解析.html
基本上,由于现在所有文件都有.php扩展名,我想重写所有html的url文件成为.php
换句话说,如果有人访问:
I have changed a website from .html extensions to .php; the file names are the same, and there are thousands of files. There is php code now which cannot be parsed with .html
Basically, since now all the files have a .php extension, I want to rewrite the url of all html files to become .php
In other words, if someone visits:
mysite.com/page.html
然后他们被带到:
then they are taken to:
mysite.com/page.php
此外,我需要它来加载.php页面,而不仅仅是更改URL。
如何在.htaccess中执行此操作?
ps最后看起来似乎是stackoverflow的可行替代方案!一些**洞接受了这个问题并说了重复的问题并且链接到一篇关于htaccess基础知识的文章。他们显然不知道复制这个词是什么意思!那个通用页面甚至没有任何与我的问题相近的东西!更不用说另一个问题恰恰相反,没有人说是重复!
推荐答案
你应该多使用谷歌。 ..
在Apache下有一些关于URL重写主题的非常好的文章...
一些样本开头:
< a href =http://httpd.apache.org/docs/2.0/misc/rewriteguide.html> http://httpd.apache.org/docs/2.0/misc/rewriteguide.html [< a href =http://httpd.apache.org/docs/2.0/misc/rewriteguide.htmltarget =_ blanktitle =New Window> ^ ]
http://24ways.org/2013/url-rewriting-for-the-fearful/ [ ^ ]
You should use Google more...
There are some very nice articles about the subject of URL rewriting under Apache...
Some samples to start with:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html[^]
http://24ways.org/2013/url-rewriting-for-the-fearful/[^]
这篇关于如何重写.html网址。 php文件使用.htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!