有没有一种简单的方法,以避免创建的所有文件夹 [英] is there an easy way to avoid creating all the folders
问题描述
好了,所以我有这个网站 ....与网址
Ok so I have this site.... with the url
http://posnation.com/
和有很多的网页,我需要保存的URL结构....像这样
and there are alot of pages that i need to save the url structure for....like this
http://posnation.com/restaurant_pos
http://posnation.com/quickservice_pos
http://dev.posnation.com/retail_pos
转......
ext....
这是我现在的问题是,我要保存相同的URL对所有这些网页,我期待的最好的方法。现在它的工作方式是它完成了一个code在MIVA,我们下车MIVA ....我知道我可以创建一个文件夹命名为restaurant_pos或任何URL是开创there.This的index.php文件方法将工作,但问题是我需要做的这600不同的页面,我不觉得自己在最好的办法创造600文件夹。
The problem that i have now is that i want to save the same url for all these pages and I am looking for the best approach. The way its working now is its done with a code in miva and we are getting off miva.... I know I can create a folder named restaurant_pos or whatever the url is and create an index.php in there.This approach will work but the problem is I need to do this for 600 different pages and I dont feel like creating 600 folders in the best approach.
任何想法
推荐答案
您应该使用的.htaccess来路由所有请求到一个单一的文件,说的index.php,做从那里根据请求的URL服务。
You should use .htaccess to route all the requests to a single file, say index.php and do the serving from there based on the requested URL.
在服务器的根目录下的.htaccess文件将路由所有的请求到您的index.php:
The following .htaccess file on the server root will route all the requests to your index.php:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L]
</IfModule>
现在你应该解析$ _REQUEST ['路线'],以确定哪些文件,你应该服务。以下是这将成为基于URL(例如:POS)的最后一个元素在页面上的一个例子
Now you should parse the $_REQUEST['route'] to identify which file you should serve. Here is an example that will serve a page based on the last element of the URL (ex: pos):
<?php
$parts = explode($_REQUEST['route']);
if ($parts[count($parts) - 1] == 'pos') {
include "pages/pos.php";
}
当然你需要编写自己的逻辑,上述仅仅是一个例子。
Definitely you'll need to write your own logic, the above is just an example.
希望这有助于。
这篇关于有没有一种简单的方法,以避免创建的所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!