.htaccess para crear URL compatibles con los motores de búsqueda

I am looking for a way to get rid off the .php extension from my file i have just got a static website with index.php and map.php

I have tried lots of different tutorials but none work i just want the following.

http://example.co.uk/map.php becomes http://example.co.uk/map/


http://example.co.uk/index.php becomes http://example.co.uk/

Can you do this with a static file i have tried so many different options and none have worked for me.

i have tried this.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/(.*)/$ map.php

Cualquier ayuda por favor.

preguntado el 08 de noviembre de 11 a las 16:11

1 Respuestas

Prueba esta

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^map/?$ map.php [NC,QSA,L]

RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC]
RewriteRule (.*) http://www.domain.com/ [R=301,L]

# if you have more than one file like map, you can use this
# this will redirect everything to .php like: test/ => test.php
# RewriteRule ^([a-z0-9_\-]+)/?$ $1.php [NC,QSA,L]

respondido 09 nov., 11:03

this didnt work i have no idea why do i need to set something up with my hosting ??? - DCHP

maybe mod_rewrite is not enable, did you put this @ the root of your website? - Libro de Zeus

Hi i think i am get close i have added a folder now with an index file in and it redirects straight back to home www.example.com so it is working but when i try to go to www.example.com/map/ i get this error. The requested URL /domains/t/w/example.com/public_html/map.php was not found on this server. but it is their definately where am i going wrong ????????? - DCHP

hi finally got it working with a mashup of wordpresses .htaccess and yours here is my finally result i have no idea how this works i think it needed the RewriteBase / could you explain <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC] RewriteRule (.*) twoogle.co.uk [R=301,L] RewriteRule ^([a-z0-9_\-]+)/?$ $1.php [NC,QSA,L] </IfModule> - DCHP

The RewriteBase directive explicitly sets the base URL for per-directory rewrites. httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase - Libro de Zeus

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.