Solved

RewriteRule MUST require specific ending

Posted on 2006-11-19
1
160 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
ID: 17977461
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl Multi-exec 13 72
Xampp Not Stopping 9 42
Apache SSL and mod_rewrite not working 8 193
htaccess file 3 88
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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