Mod Rewrite rule help. Just 1 rule.

Posted on 2007-07-31
Last Modified: 2010-03-04
On a linux server, I need help with a mod_rewrite rule please.

Actual url: phrase here
Desired url:

Thanks, Greg Schipper Phone: 210-493-6193
Question by:gregsschipper
    LVL 16

    Expert Comment

    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

    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 Phone: 210-493-6193
    LVL 1

    Accepted Solution

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

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting ( to http…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now