Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have wordpress installed in a directory called welcome, and /welcome/samples is a "page" (created via Wordpress). It's has a php template waiting for a $_REQUEST['category']

When a user goes to /welcome/samples/fun, I want to have "fun" passed to the samples php template in the form welcome/samples/?category=fun

But I want the URL to remain in its original form - it's currently replacing the it with the ugly "?cat...etc"

# Outside the wordpress block so it won't be overwritten
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^samples/([^/]+)$ /welcome/samples?cat=$1 [R,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /welcome/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /welcome/index.php [L]

# END WordPress

I tried Rewriting with simply samples?cat=$1 but I was getting a 404. I tried putting in the RewriteBase /welcome/ in the first block. without the [R] flag it doesn't work at all. I keep trying different permutations... and failing:(

Perhaps I'm missing some basic concepts... thanks if you take the time to even read through this:)


share|improve this question

This seemed to work for me:

RewriteRule ^welcome/samples/([^/]+)$ /welcome/samples?cat=$1

I noticed that you're matching on ^samples… but actually there's no RewriteBase yet, so you need to match more (^welcome/samples…)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.