Mod Rewrite rule help. Just 1 rule.

On a linux server, I need help with a mod_rewrite rule please.

Actual url: www.domain.com/rh/page.php?str=keyword phrase here
Desired url: www.domain.com/rh/keyword-phrase-here.html

Thanks, Greg Schipper www.AdventDigital.net Phone: 210-493-6193
gregsschipperAsked:
Who is Participating?
 
myrondCommented:
do this:
RewriteEngine on
RewriteCond   %{REQUEST_FILENAME}  !-d
RewriteCond   %{REQUEST_FILENAME}  !-f
RewriteRule ^([^a-z].*).html$                   page.php?str=$1
0
 
HackneyCabCommented:
Try this in a .htaccess file in the /rh/ directory:

RewriteRule ^([a-z_-])\.html$ page.php?str=$1

That should allow keywords that contain lowercase letters, underscores and hyphens, but you can change the pattern to suit you.
0
 
gregsschipperAuthor Commented:
Thank you HackneyCab.
This was tried on to servers already performing mod_rewrite, and both give 404 error.
Contents of .htaccess file
RewriteEngine on
RewriteRule ^([a-z_-])\.html$ page.php?str=$1
Any suggestions?
Thanks, Greg Schipper www.AdventDigital.net Phone: 210-493-6193
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.