简体   繁体   English

mod_rewrite掩码文件夹名称

[英]mod_rewrite mask folder name

Looking to do the following: 希望执行以下操作:

domain.com - root directly with unique files that are different than individual cities. domain.com直接以不同于各个城市的唯一文件作为根。

domain.com/city_name - this folder will have CMS elements and individual content based on the city the user ends up at. domain.com/city_name此文件夹将包含CMS元素以及根据用户所在城市而定的个人内容。

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['']; 最终,所有用于控制CMS的文件都位于/city_name但是我分页了一个名为pageLoader.php?page = $ 1的文件,因此可以执行$_GET['']; and request the name of the city they've entered, example: domain.com/vancouver 并要求他们输入的城市名称,例如: domain.com/vancouver

So, what I need to do is "mask" the city_name folder with 因此,我需要做的是使用“掩码” city_name文件夹

/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. 在项目的截止日期之前,任何响应都是超级成功的,并且很难弄清这一点。

Thanks. 谢谢。

EDIT: basically need to read the /city_name folder when someone types in /vancouver 编辑:当有人输入/ vancouver时,基本上需要读取/ city_name文件夹

First, are you using Apache or IIS? 首先,您使用的是Apache还是IIS? Anyway I guess you can do the following... 无论如何,我想您可以执行以下操作...

In the .htaccess (Apache): 在.htaccess(Apache)中:

RewriteEngine On

RewriteCond %(REQUEST_FILENAME) -d

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

In the web.config (IIS) 在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM