<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Isern Palaus &#187; apache</title>
	<atom:link href="http://blog.ipalaus.es/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ipalaus.es</link>
	<description>PHP, CodeIgniter y jQuery</description>
	<lastBuildDate>Sat, 10 Apr 2010 13:10:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CodeIgniter: mod_rewrite</title>
		<link>http://blog.ipalaus.es/codeigniter-mod_rewrite</link>
		<comments>http://blog.ipalaus.es/codeigniter-mod_rewrite#comments</comments>
		<pubDate>Sun, 30 Mar 2008 15:17:12 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=12</guid>
		<description><![CDATA[Uno de los principales inconvenientes de CodeIgniter es, en parte, visual en la dirección URL. Solemos tener nuestros programas con http://localhost/index.php/controlador/funcion y seguramente quedaría mucho mejor algo tipo: http://localhost/controlador/funcion, ¿verdad? Pues bien, para hacer esto necesitaremos usar Apache y el modulo mod_rewrite.
Para empezar será necesario saber si estamos usando mod_rewrite en Apache. Lo más fácil <a href="http://blog.ipalaus.es/codeigniter-mod_rewrite" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Uno de los principales inconvenientes de CodeIgniter es, en parte, visual en la dirección URL. Solemos tener nuestros programas con <em>http://localhost/index.php/controlador/funcion </em>y seguramente quedaría mucho mejor algo tipo: <em>http://localhost/controlador/funcion</em>, ¿verdad? Pues bien, para hacer esto necesitaremos usar <a href="http://www.apache.org">Apache</a> y el modulo <em>mod_rewrite</em>.</p>
<p>Para empezar será necesario saber si estamos usando <em>mod_rewrite</em> en Apache. Lo más fácil es, directamente, ir al archivo de configuración (el archivo <strong>http.conf</strong>) y buscar: mod_rewrite.so. Deberíamos encontrar la siguiente línea:</p>
<p>[code]LoadModule rewrite_module modules/mod_rewrite.so[/code]</p>
<p>Sin embargo, si esta contiene un símbolo de almohadilla (<strong>#</strong>) es que no esta activado. Si lo contiene al principio, lo borramos, guardamos y reiniciamos el servidor. Así, <em>mod_rewrite</em> se iniciará cada vez al iniciar Apache.</p>
<p>Ahora es el momento de crear nuestro archivo de configuración especifico en el directorio donde este nuestro <strong>index.php</strong>. A este archivo le pondremos de nombre <strong>.htaccess</strong> y contendrá lo siguiente:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_about(1)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;">RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.*)$ index.php/$1 [L]<br />
<br />
# If we don't have mod_rewrite installed, all 404's<br />
# can be sent to index.php, and everything works as normal.<br />
# Submitted by: ElliotHaughin<br />
ErrorDocument 404 /index.php</div></div>
<p>Bien, con esto ya nos ocupamos de cuando se acceda a nuestra web automáticamente, lo que hace el servidor web, es catalogar como si accediéramos a la misma pero con <em>index.php/</em> al principio. Solo nos queda una cosa, que <a href="http://www.codeigniter.com">CodeIgniter</a> nos construya los enlaces sin el <strong>index.php/</strong>. De este modo, accedemos al archivo <strong>config.php</strong> y cambiaremos la variable <em>$config['index_page']</em>:<br />
De:<br />
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_about(2)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'index_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;index.php&quot;</span><span style="color: #339933;">;</span></div></div></p>
<p>A:<br />
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_about(3)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'index_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span></div></div><br />
Y esto es todo para tener unas direcciones URL mucho más limpias. Espero que les haya ayudado de nuevo y hasta pronto.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/codeigniter-mod_rewrite/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
