本文介绍了的.htaccess加载索引文件的URL含有不同数量的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有目录的地区,在我的根:

lets say I have directory regions in my root:

root/regions

我要加载它位于地区index.php文件文件夹,如果用户访问下列之一:

I want to load index.php file which is located in regions folder if user visits one of the following:

http://www.example.com/regions/united-kingdom
http://www.example.com/regions/united-kingdom/london
http://www.example.com/regions/united-kingdom/londom/rm8-16de

国家,城市和后期code不存在的目录!如何做到这一点?预先感谢您!

Country, city and post code dont exist as directory !How to do that? Thank you in advance!

推荐答案

在你的区域/的.htaccess ,你可以有这样的.htaccess:

In your regions/.htaccess you can have this .htaccess:

DirectoryIndex index.php
RewriteEngine On
RewriteBase /regions/

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

这篇关于的.htaccess加载索引文件的URL含有不同数量的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 20:00