Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET Architect PHP MySQL url
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 22-Feb-13 0:43am
AndyInUK3.4K
Comments
AnkitGoel.com at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 152
2 ProgramFOX 130
3 Maciej Los 130
4 den2k88 80
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100