Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

RewriteRule MUST require specific ending

Posted on 2006-11-19
1
Medium Priority
?
169 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 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