tags:

views:

159

answers:

2

This has been asked on here (over a year ago), but apparently not answered, and WordPress is always evolving so maybe theres a good solution now. I want to pass variables to a WordPress page via the url (similar to CodeIgniter uri helper segments).

Currently I can do this...

My profile page is: http://website.com/profile

I can pass a variable like this: http://website.com/profile?username=johndoe

I want to pass the variable in like this: http://website.com/profile/johndoe or http://website.com/profile/username/johndoe

There has to be some sort of helper function, right?

A: 

Assuming that your wp installation is using permalinks, so the .htaccess features, you should put on TOP of your .htaccess file the following :

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^profile/(.*)$ /profile?username=$1 [NC]
Simone Margaritelli
404 error if I try website.com/profile/johndoe
mikemick
A: 

Append to your .htaccess file in the root folder something like

 RewriteRule ^profile/?([_0-9a-z-]+)?/?$ http://website.com/profile?username=$1 [R=301,L]

after the other RewriteRules

Alex Bilbie
Yeah, thats what has been posted in most other forums I found where people were asking the same question. But, it apparently hasn't worked for them, nor me, unfortunately.My WordPress permalink structure is:/%year%/%monthnum%/%postname%/And the .htaccess file rules that WP created were:<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /learnwake.com/RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /learnwake.com/index.php [L]</IfModule>
mikemick
Wow, sorry for that code mess... The line breaks weren't preserved.
mikemick