.htaccess - PHP Multiregional Site - Mod rewrite - Read $_GET variables -


i te start new php project, i'm looking answers first before start since have little php experience.

here's case:

i use simple php $_get variables include more information in url. http://mywebsite.eu/subject.php?region=nl goes http://mywebsite.eu/nl/subject
http://mywebsite.eu/subject.php?region=be goes http://mywebsite.eu/be/subject
http://mywebsite.eu/subject.php?region=global goes http://mywebsite.eu/subject


my questions:
+ how create clean urls example above
+ how can retrive variables cleaned url (reverse) http://mywebsite.eu/nl/subject $_get['region']
+ if know way figure out visitors country code. let me know :d

i hope explanation makes sense. --i know there're lots of similar topics, hard find topic matching case--

you can write rewirte rules in .htaccess file

rewriteengine on rewriterule ^([^//]+)/([^//]+)$ $2.php?region=$1 [qsa,l] 

$1 contain regions nl,ar ... , $2 have subject , land subject.php?region=nl

just echo $_get['region'] have nl


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -