问题
Looking to do the following:
domain.com
- root directly with unique files that are different than individual cities.
domain.com/city_name
- this folder will have CMS elements and individual content based on the city the user ends up at.
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.
Thanks.
EDIT: basically need to read the /city_name folder when someone types in /vancouver
回答1:
First, are you using Apache or IIS? Anyway I guess you can do the following...
In the .htaccess (Apache):
RewriteEngine On
RewriteCond %(REQUEST_FILENAME) -d
RewriteRule ^(.*)$ index.php?page=$1
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>
来源:https://stackoverflow.com/questions/11567187/mod-rewrite-mask-folder-name