Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    indirizzi web dei blog leggibili (non numerici)??

    ciao a tutti, qualcuno può spiegarmi come fanno i cms tipo wordpress e simili a generare come indirizzo http il titolo dell'articolo?

    esempio: miosito.blabla/ilmioprimopost invece di miosito.blabla?id=1

    come si chiama una funzione del genere e come si implementa nei propri progetti php?

    grazie

  2. #2
    Quello che dici ha un nome specifico: URL REWRITING e lo monti dentro il file .htaccess

  3. #3
    grazie della risposta, inizio a leggere in giro che é abbastanza difficile, me lo puoi confermare?

    e poi i motori di ricerca hanno ancora problemi con indirizzi dinamici?

  4. #4
    phpneo, dipende da quanto sei "expert"

    Guarda questi esempi

    codice:
    1)Rewriting product.php?id=12 to product-12.html
     
    It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.
     
    RewriteEngine on
     RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1
     
    2) Rewriting product.php?id=12 to product/ipod-nano/12.html
     
    SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.
     
    RewriteEngine on
     RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2
     
    3) Redirecting non www URL to www URL
     
    If you type yahoo.com in browser it will be redirected to www.yahoo.com. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about SEO friendly redirect (301) redirect in php and .htaccess.
     
    RewriteEngine On
     RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$
     RewriteRule (.*) http://www.optimaxwebsolutions.com/$1 [R=301,L]
     
    4) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
     
    Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.
     
    RewriteEngine On
     RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
     RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
     
    5) Redirecting the domain to a new subfolder of inside public_html.
     
    Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, www.test.com point out to the files inside “new” folder.
     
    
    
    RewriteEngine On
     RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
     RewriteCond %{HTTP_HOST} ^www\.test\.com$
     RewriteCond %{REQUEST_URI} !^/new/
     RewriteRule (.*) /new/$1

  5. #5
    Es. se l'url è così formattato www.tuosito.com/tutto-il-testo-che-vuoi/89, con questa regola reindirizzi a www.tuosito.com/index.php?id=89
    codice:
    RewriteRule ^([a-z\-]+)/([0-9]+)$ index.php?id=$2 [L]
    $2 è il valore numerico che è presente nell'url

    Nel caso che dici tu, devi strutturare il testo dell'url, che salvi sul db, e poi lo usi per la querystring
    es.
    codice:
    RewriteRule ^([a-z\-]+)$ corso.php?nome_prodotto=$1 [L]
    $1 in questo caso è il testo che viene letto nell'url, dopo al dominio

    Ma per fare ciò devi sincerarti se i server ti consente di far eil rwwrite, ovvero se il module mod_rewrite è presente

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.