Home > Backend Development > PHP Tutorial > php url地址重写的有关问题

php url地址重写的有关问题

WBOY
Release: 2016-06-13 12:56:59
Original
921 people have browsed it

php url地址重写的问题
小弟学习php过程中,提出一个很简单的问题:
比如:真实url:localhost/test/controller/index.php,想在地址栏显示为localhost/test/或localhost/test/index.php,即隐藏真实的url。
我在test下面建立一个index.php,配置了apache的VirtualHost,里面设置servername为test,并写了一个header()跳转到controller文件夹下面,结果不行。有哪位大侠知道怎么搞,给个最简单的例子

php url rewrite
------解决方案--------------------
在localhost目录下建一个.htaccess文件
记事本打开输入如下两行
RewriteEngine on
RewriteRule ^test/index.php$ test/controller/index.php
保存
访问localhost/test/index.php看下能不能访问
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template