Solved

RewriteRule MUST require specific ending

Posted on 2006-11-19
1
155 Views
Last Modified: 2011-10-03
Hello,

I use this in my .htaccess file:

             RewriteRule ^(.*)\.html index.php?page=$1 [L]

to re-write
            page.html
as
            index.html?page=page

The problem is that it ALSO rewrites

            page.html/directory
as
            index.html?page=page

and
            page.htmlzzzzzzzzzzz
as
            index.html?page=page


I ONLY want it rewritten if if ends in .html OR has a ? at the end (like .html?get=info )

Any ideas?

Thanks!

0
Comment
Question by:hankknight
1 Comment
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
Comment Utility
RewriteRule ^(.*)\.html$ index.php?page=$1 [L]
$ matches end of string
but note, that the above will rewrite
subfolder/something.html -> index.php/page=subfolder/something
To fix it
RewriteRule ^([^/])\.html$ index.php?page=$1 [L]
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

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 http://domain.com (http://domain.com) to http…
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 …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

12 Experts available now in Live!

Get 1:1 Help Now