Jump to content

[Resolvido] rewrite url em .htaccess

Recommended Posts


Boa tarde, tenho o seguinte link no site: detalhes_casa.php?casa_id=30 e quero que fique detalhes_casa/id/30/. Criei um ficheiro .htaccess com o seguinte código

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^ casa_id/([a-zA-Z0-9]+)/$ detalhes_casa.php?casa_id=$1

só que não faz nada, alguém me pode dar uma ajuda ?

Edited by brunoais

Share this post

Link to post
Share on other sites

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]

Vê se ajuda, se utilizares um form qualquer com o PHP_SELF na mesma pagina, vais provavelmente necessitar do str_replace.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.