I would like (for instance)

discuss/1/title/where-are-you

to output

discussPage.php?id=1&title=where-are-you

I've the next instructions inside a .htaccess file which is incorporated in the same directory as discussPage.php:

# Enable Rewriting
RewriteEngine on

# Rewrite user URLs
#   Input:  discuss/ID/title/TITLE
#   Output: discussPage.php?tid=NAME&title=TITLE

RewriteRule ^discuss/(\w+)/(\w+)/(\w+)/?$ discussPage.php?id=$1&title=$3

Right now i'm obtaining a 404 error after i attempt to go to a page like discuss/1/title/where-are-you despite the fact that discussPage.php?id=1&title=where-are-you works fine.

P.S. mod_rewrite is enabled (i have tried personally it for other reasons).

Your condition is the fact that w doesn't match the "-" within the last bit.

You can just allow dashes inside utilizing a larger character class like [\w-]+. I'd be cautious with solutions like [^/] simply because they allow anything except a slash, quite permissive. Whitened-lists will always be safer and steer clear of surprises.

# Enable Rewriting
RewriteEngine on

# Rewrite user URLs
#   Input:  discuss/ID/title/TITLE
#   Output: discussPage.php?tid=NAME&title=TITLE

RewriteRule ^discuss/(\w+)/(\w+)/([\w-]+)/?$ discussPage.php?id=$1&title=$3

Observe that the - needs to be last within the character class, or else you should escape it, if it's among two other figures it reacts like a range, as with [a-z].

To debug, you could echo $_SERVER['QUERY_STRING'];

However I believe the right code could be something similar to this.

RewriteEngine on
RewriteBase /

    RewriteRule ^discuss/([0-9]+)/title/([a-z0-9\-]+)?$ discussPage.php?id=$1&title=$2 [NC,QSA]

You might like to fix your RewriteBase value, though.

Also - as observed in the final condition, you are able to have only alphanumeric figures and hyphens within the where-are-you part. (but something informs me you will not be requiring other figures!)

Works best for me:

RewriteEngine On
RewriteBase /
RewriteRule ^discuss/([^/]+)/([^/]+)/([^/]+)/?$ discussPage.php?id=$1&title=$3 [R]