Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
AnkitGoel.com 12-Jun-14 6:47am    
Dear Andy,
This kind of URLs help when URL rewriting is implemented in your website. Support you have two URLs www.xyz.com/sports/car.php and www.xyz.com/technology/car.php

The original page in your website might by anyhting like xyz.php but, using this technique you are passing some query string parameters to your web server such as- Sports and Car in first URL and technology and car in second URL. You do not have to write something like- www.yyz.com/articles?id=454501 and www.yyz.com/articles?id=43401

So, when a user hits any one of these URLs, physically a single page will server the requests from both URLs but, you will be able to change the content according to the URL.

And, lastly it is also SEO friendly and easy to remember.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900