Reputation: 13
My first question here hope to find the right answer to my problem.
Here it is:
I try to transform http://mysite.it/home.php?pagina=ciao
to http://mysite.it/ciao
I put inside my .htaccess
this:
RewriteEngine On
RewriteRule ^home.php?(.*)$ $1
It shows me: http://mysite.it/?pagina=ciao
I know that something is wrong in the RewriteRule but I don't understand how to pick only after home.php?pagina=
to take ciao
,I have this on my PHP page $get= @$_GET ['pagina'];
I say thanks in advice and hope to resolve this.
Upvotes: 1
Views: 75
Reputation: 784898
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /home\.php\?pagina=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /(home)\.php\s [NC]
RewriteRule ^ %1 [R=302,L]
RewriteRule ^(home)/?$ $1.php [L,NC]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)/?$ home.php?pagina=$1 [L,QSA]
Upvotes: 1
Reputation: 347
I believe what you're looking for is :
RewriteEngine On
RewriteRule ^([A-Za-z]+)$ /home.php?pagina=$1
I hope you're not doing :
require_once($get);
after that code, since that would be very dangerous...
Upvotes: 0