Ativar o mod_rewrite e permitir url amigáveis em seus scripts
mod_rewrite é o nome do módulo do Apache responsável por permitir que você utilize isso:
http://www.aprimorar.com/hospedagem_web/planos/
Ao invés disso:
http://www.terra.com.br/index.php?aqq=qedqweq
São as famosas “URL amigáveis”, ou seja, são mais limpas, e já dizem a que vieram logo de cara.
Para trabalhar com URL amigáveis em PHP são necessários alguns ajustes bem simples no servidor, e um bocado de código a mais no script.
Vamos ao que interessa:
1° Rode o comando:
# nano /etc/httpd/conf/httpd.conf
2° Procure por essas linhas:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
Veja que quase no final da linha há a seguinte palavra:
AllowOverride None
Então mude para:
AllowOverride All
3° Agora reinicie o Apache:
# service httpd restart