php - RewriteEngine to hide extensions and GET -


how can rewrite url ?

http://website.com/file.php?lang=en http://website.com/file/en

file name , parameters can change, found lot of topics put did not found combination of both extensions , parameters

update: work hide php extension how add parameters

# turn mod_rewrite on rewriteengine on  # hide .php extension # externally redirect /dir/file.php /dir/file rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r=302,l]  # internally forward /dir/file /dir/file.php rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ $1.php [l,qsa] 

from code , comment can 1 of answers :p

in order new http://website.com/file.php?lang=en http://website.com/file/en in place have .htaccess this:

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{document_root}/$1.php -f rewriterule ^([^/]+)/([^/]+)/?$ /$1.php?lang=$2 [l,qsa]  # hide .php extension # externally redirect /dir/file.php /dir/file rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r=302,l]  # internally forward /dir/file /dir/file.php rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{document_root}/$1.php -f rewriterule ^(.+?)/?$ $1.php [l] 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -