Best way to determine web application urls

I have always found that defining URLs for other "pages" in a web application seems either awkward, but fragile or bloated.

eg. you have an application that manages customers, sales, prospects, and therefore has the following "pages".

  • Customerlist
  • viewcustomer
  • editcustomer
  • addcustomer
  • viewcontact
  • editcontact
  • addcontact
  • perspective (x3? x4?)
  • sales (x?)
  • product (x?)
  • request (x?)
  • forecast (x?)
  • etc.....

As the application grows, the number of pages increases to 100+ URLs in no time.

, / URL- , 100 / , 2 3 "this".

- (ASP, JSP, PHP, RoR, Python ..), PHP ( MVC). , ASP.Net Rails " " , .

Update:

MVC- PHP-, MVC. , URL , :

$URLs['CUSTOMER_ORDER_CONTACTS'] = '/customerordercontacts.php';
$URLs['CUSTOMER_PRODUCTS_EDIT'] = '/editcustomerproducts.php';
//etc.

" " , , / URL- ... .

, , , , , . @Blixt - , / ... URL , :

: ...

//pseudo code
$contacts = $customer.getContacts();

//previous rendering list of links
foreach($contacts as $key => $value){
  echo('<a href="'.$URLs['CUSTOMER_CONTACT_VIEW'].'?customer='.$custID.'&contact='.$key.'">'.$value.'</a>');
}

//new rendering list of links
foreach($contacts as $key => $value){
  echo('<a href="/customer/'.$custID.'/contact/'.$key.'">'.$value.'</a>');
}
+3
4

URL URL-, (, , URL, ).

:

# All customers:
/customers/
# New customer:
/customers/new
/customers/?new # another version if you don't think "new" deserves its own path
# Existing customer:
/customers/123/
/customers/123 # another version if you want the concept that it a page, not a
               # directory
# Edit customer:
/customers/123/edit
/customers/123?edit

# Some sub-list for a customer:
/customers/123/orders/

# and so on...

, , . , - "", - "". , (/customers/?new).

, URL-, , -. , "", URL- ( - , , , .) , , (regex):

^/customers/$ -> CustomerList
^/customers/(\d+)$ -> Customer # This will check the query string for "edit" etc
                               # to determine which mode to use.
^/customers/(\d+)/orders/$ -> OrderList
+1

CodeIgniter (PHP) URL- , ..

/customers/list/3

Customers->list('3'). , URL-. , .

Django (Python) , , . , URL- , .

, .

,

0

in PHP , :

www.example.com/application/controller/action/parameter

application

controller parent application

action ( ) OR application->controller->action, .

, .

, .

0

URL- . , , , - . Google, :

URL

from http://www.google.com/webmasters/docs/search-engine-optimization-starter-guide.pdf:

URL-. URL- , . , . .

URL- . URL- , ( URL), URL- .

URL

http://www.google.com/support/webmasters/bin/answer.py?answer=76329:

URL- . , URL- ( , ).

URL-. URL- http://www.example.com/green-dress.html , http://www.example.com/greendress.html. (-) (_) URL-.

URL-, , , URL-, . , Google , , .

0

Source: https://habr.com/ru/post/1714781/


All Articles