Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Mod Rewrite rule help. Just 1 rule.

Posted on 2007-07-31
Medium Priority
Last Modified: 2010-03-04
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
Question by:gregsschipper
LVL 16

Expert Comment

ID: 19608291
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.

Author Comment

ID: 19608647
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

Accepted Solution

myrond earned 2000 total points
ID: 19650251
do this:
RewriteEngine on
RewriteCond   %{REQUEST_FILENAME}  !-d
RewriteCond   %{REQUEST_FILENAME}  !-f
RewriteRule ^([^a-z].*).html$                   page.php?str=$1

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question