Diferencia entre revisiones de «Usuario:Lmorillas/desarrollo web servidor/php/urls amigables»
De WikiEducator
(→Emular carpetas) |
(→Crear página html) |
||
(3 revisiones intermedias por el mismo usuario no mostrado) | |||
Línea 6: | Línea 6: | ||
== Algunos docs== | == Algunos docs== | ||
+ | * http://pixelcode.co.uk/tutorials/webmaster/clean-urls-with-mod_rewrite/ | ||
+ | * http://www.emenia.es/como-crear-urls-amigables-con-htaccess/ | ||
* http://www.miguelmanchego.com/2010/php-friendly-url-amigable/ | * http://www.miguelmanchego.com/2010/php-friendly-url-amigable/ | ||
* http://www.baluart.net/articulo/urls-amigables-con-php | * http://www.baluart.net/articulo/urls-amigables-con-php | ||
* http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ | * http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ | ||
* http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/ | * http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/ | ||
+ | * http://www.pmwiki.org/wiki/Cookbook/CleanUrls | ||
+ | == Ejemplos de uso == | ||
+ | * http://sergioglez.webcindario.com/cargarArticulo.php?id=59 | ||
== Activar mod_rewrite == | == Activar mod_rewrite == | ||
sudo a2enmod rewrite | sudo a2enmod rewrite | ||
sudo service apache2 restart | sudo service apache2 restart | ||
− | |||
− | |||
== Emular carpetas == | == Emular carpetas == | ||
Línea 32: | Línea 35: | ||
index.php?page=mipagina | index.php?page=mipagina | ||
mipagina.html | mipagina.html | ||
+ | |||
+ | == Quitar extensión .php == | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{REQUEST_FILENAME} !-d | ||
+ | RewriteCond %{REQUEST_FILENAME} !-f | ||
+ | RewriteRule (.*) $1.php [L] | ||
+ | |||
+ | {{Actividad| | ||
+ | '''Comprueba los ejemplos de''' http://www.codeofaninja.com/2013/04/mod-rewrite-url.html | ||
+ | }} |
Última revisión de 18:52 31 ene 2014
Contenido
Clean URL - Friendly URL
Fáciles de recordar, buenas para los usuarios y para los buscadores
Algunos docs
- http://pixelcode.co.uk/tutorials/webmaster/clean-urls-with-mod_rewrite/
- http://www.emenia.es/como-crear-urls-amigables-con-htaccess/
- http://www.miguelmanchego.com/2010/php-friendly-url-amigable/
- http://www.baluart.net/articulo/urls-amigables-con-php
- http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
- http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/
- http://www.pmwiki.org/wiki/Cookbook/CleanUrls
Ejemplos de uso
Activar mod_rewrite
sudo a2enmod rewrite sudo service apache2 restart
Emular carpetas
RewriteBase /~lm/ejerciciosclasephp/ RewriteRule /local/(.*)/ index.php?page=local&link=$1 RewriteRule local/(.*) index.php?page=local&link=$1
index.php?page=local&link=restaurante-san-jose www.misitio.com/local/restaurante-san-jose/
Crear página html
RewriteRule (.*)\.html$ index.php?page=$1 index.php?page=mipagina mipagina.html
Quitar extensión .php
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) $1.php [L]
Comprueba los ejemplos de http://www.codeofaninja.com/2013/04/mod-rewrite-url.html
|