mod_rewrite掩码文件夹名称 [英] mod_rewrite mask folder name

查看:67
本文介绍了mod_rewrite掩码文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望执行以下操作:

domain.com-直接以不同于各个城市的唯一文件为根.

domain.com - root directly with unique files that are different than individual cities.

domain.com/city_name-此文件夹将具有CMS元素以及根据用户最终所在城市而定的单个内容.

domain.com/city_name - this folder will have CMS elements and individual content based on the city the user ends up at.

最终,所有用于控制CMS的文件都将位于/city_name中,但是我对名为pageLoader.php?page = $ 1的文件进行了分页,因此我可以执行$_GET[''];并请求输入其所在城市的名称,例如:domain.com/vancouver

Ultimately, all files to control the CMS will be in /city_name but I page a file called pageLoader.php?page=$1 so I can do a $_GET['']; and request the name of the city they've entered, example: domain.com/vancouver

所以,我需要做的是使用

So, what I need to do is "mask" the city_name folder with

/vancouver, /los-angeles etc...

这可能吗?我将如何去做.

Is this possible? How would I go about doing this.

在项目的截止日期之前,任何响应都是非常成功的,并且很难弄清这一点.

ANY RESPONSE IS SUPER HELPFUL on a deadline for a project and having difficulties figuring this out.

谢谢.

当有人输入/vancouver时,基本上需要读取/city_name文件夹

basically need to read the /city_name folder when someone types in /vancouver

推荐答案

首先,您使用的是Apache还是IIS?无论如何,我想您可以执行以下操作...

First, are you using Apache or IIS? Anyway I guess you can do the following...

在.htaccess(Apache)中:

In the .htaccess (Apache):

RewriteEngine On

RewriteCond %(REQUEST_FILENAME) -d

RewriteRule ^(.*)$ index.php?page=$1

在web.config(IIS)

In the web.config (IIS)

<rule name="rewrite" stopProcessing="true" >
    <match url="^(.*)$" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="%(REQUEST_FILENAME)" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php?page={R:1}" appendQueryString="false" />
</rule>

这篇关于mod_rewrite掩码文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆