url中的虚拟文件夹/目录 [英] virtual folder/directory in url

查看:122
本文介绍了url中的虚拟文件夹/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我的一位同伴问我,如果在网址中有一个虚拟文件夹,这是一个很好的解决方案吗?



基本上,他们正在为文章网站开发一个正在开发的CMS系统(他们发表了许多文章)。



例如 - www。 xyz.com/news/sports/index.php



这里的新闻和体育文件夹是虚拟的。



此链接也可以作为 -



www.xyz.com/index.php



或www.xyz.com/dir/etc/index.php



优点 -



1.)无需为文章创建文件夹或类别。

2.)他们只需要按照自己喜欢的名称命名虚拟目录。将来,如果管理员想要一起创建一个新的菜单系统,他们可以改变它。他们不必为文章创建文件夹或目录。

3.)这种方式网址可以非常友好。



缺点 -



1.)他们不能让两页/文章相同。



例如 - 在这种情况下,他们无法创建另一个index.php页面。



因此,如果管理员尝试按名称创建新页面/文章index.php - 他会收到一条错误,说此页面/文章已经存在。请选择其他名称。



Tbh,我认为这可能会在未来造成很多冲突,他们想用同一个名字命名两个不同类别的文章 -



例如,有两个部分 - 体育和技术以及管理员想要创建 -



www.xyz.com/sports/car.php



及类似,



www.xyz.com/technology/car.php



他们无法再次创建car.php,e如果他们想把它放在不同的类别下,因为类别都是虚拟的。



我可能完全错了,可能他们建议一个好的解决方案。你对此有何看法?这是要走的路吗?



谢谢

Hello,

One of my mate asked me if it''s a good solution to have a virtual folders in a url ?

Basically, they are working on a developing CMS system for articles website (They publish many articles).

For instance - www.xyz.com/news/sports/index.php

Here news and sports folder are virtual.

This link can also work as -

www.xyz.com/index.php

or www.xyz.com/dir/etc/index.php

Pros -

1.) There is no need to create a folder or category for an article.
2.) They only need to name the virtual directory by whatever name they like. In future, if admin wants to create all together a new menu system, they can change it. They do not have to create a folder or directory for the article to exist.
3.) This way url can be very SEO friendly.

Cons -

1.) They can not have the two pages/articles same same.

For instance - they can not create another index.php page in this scenario.

So if admin tries to create a new page/article by name index.php - he will get an error saying "this page/article already exist. Please chose another name".

Tbh, I think this can cause lot of conflicts in the future, where they want to name two articles under different category by a same name -

For instance there are two sections - sports and technology and admin wants to create -

www.xyz.com/sports/car.php

and similary,

www.xyz.com/technology/car.php

They can not create car.php again, even if they want to place it under different category as category is all virtual.

I might be completely wrong, and may be they are suggesting a good solution. What are your thoughts about it? Is this the way to go?

Thanks

推荐答案

你考虑过 URL重写 [ ^ ]?或者你在这里谈论 URL重写



你可以映射 querystrings 文件夹路径。然后根据查询字符串拉出数据并显示给用户。



ie



那里两个单独的内容为''Sorts-Car''和''Tech-Car''



你可以添加重写规则,这使得



www.xyz.com/Sports/Car/Index.php(在网络浏览器上)



to



www.xyz.com/Index.php?MainCategory=Sports&SubCategory=Car(on网络服务器)



然后在 index.php 上,拉基于参数的数据库内容。这样,您不需要为不同类别单独使用index.php。您可以根据需要添加任意数量的动态类别和子类别。
Have you consider URL Rewrite[^]? or are you talking about the URL Rewrite here?

You can map querystrings to a folder path. and then pull the data based on the querystring and show it to the user.

i.e.

There are two separate contents for ''Sorts-Car'' and ''Tech-Car''

you can add a rewrite rule which makes

www.xyz.com/Sports/Car/Index.php (on the web browser)

to

www.xyz.com/Index.php?MainCategory=Sports&SubCategory=Car (on the web server)

and then on the index.php, pull the contents from database based on the parameters. This way you do not need separate index.php for different category. and you can add as many dynamic category and sub-category as you want.


这篇关于url中的虚拟文件夹/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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