.htaccess - PHP (htaccess) rewrite with $_GET request -


i made simple framework website development.

i using url pattern:

www.example.com?r=account/login 

but change to:

www.example.com/account/login 

remove r= url.

i have seen yii framework this. couldn't find way this.

solution: add code below .htaccess

<ifmodule mod_rewrite.c>     rewriteengine on     rewriterule ^([a-za-z0-9-/]+)$ index.php?r=$1     rewriterule ^([a-za-z0-9-/]+)/$ index.php?r=$1 </ifmodule>` 

what looking seo friendly urls quite common use & implement. .htaccess basic wordpress install achieves similar goal:

# begin wordpress <ifmodule mod_rewrite.c>   rewriteengine on   rewritebase /   rewriterule ^index\.php$ - [l]   rewritecond %{request_filename} !-f   rewritecond %{request_filename} !-d   rewriterule . /index.php [l] </ifmodule> # end wordpress 

then in index.php can test doing variable dump of $_get so:

echo '<pre>'; print_r($_get); echo '</pre>'; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -