Solved

RewriteRule MUST require specific ending

Posted on 2006-11-19
1
159 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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