Reputation: 26
I have the following page:
mysite.com/var2.php?var3
I want to rewrite this so that it goes kind of as follows
mysite.com/var1/var2/var3
Upvotes: 0
Views: 33
Reputation: 2130
In your PHP code (generating HTML), you output /$var1/$var2/$var3
in the href of the link, to get your (second) example. This is the format that the world will see (an SEF or SEO format).
In your .htaccess file (Apache server, or equivalent in other servers), you have statements to rewrite the SEO form (your second example) into the dynamic form (your first example):
RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /$1.php?$2=$3 [QSA]
I'm assuming you meant in that format. There are even some more generic forms floating around on StackExchange that can handle an arbitrary number of var=value pairs.
Upvotes: 1