URL重写,PHP模板和$ _GET数组 [英] URL rewriting, PHP templating and the $_GET array
本文介绍了URL重写,PHP模板和$ _GET数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在顶层与其他文件的index.php文件,如一个名为包含文件夹的login.php,register.php。文件夹层次结构是这样的:
I have an index.php file in the top level with other files such as "login.php", "register.php" in a folder called includes. The folder hierarchy looks like this:
index.php
includes/
register.php
login.php
css/
style.css
images/
image.png
如何设置链接直接像 http://www.mydomain.com/register 然后从index.php页面调用(包括)的register.php页面?
How can I set the url to something like http://www.mydomain.com/register which then from within the index.php page calls (includes) the register.php page?
这是去了解它的最好方法是什么?
Is this the best way to go about it?
感谢
迈克
推荐答案
如果你的服务器是Apache的: 创建于根文件夹中的文件。htaccess的
If your server is Apache: Create on root folder file ".htaccess"
#.htaccess
RewriteEngine On
Options +FollowSymlinks
RewriteRule /register index.php?mode=register
//的index.php
//index.php
<?php
if(isset($_GET['mode']=='register')){
include('includes/register.php');
}
?>
这篇关于URL重写,PHP模板和$ _GET数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文