?
Solved

Redirect all HTML pages to home page with .htaccess

Posted on 2011-05-03
4
Medium Priority
?
310 Views
Last Modified: 2012-05-11
I need to temporarily redirect all files on a web site with the extension .htm or .html to the home page (index.html)

I have tried this:

RewriteEngine On
RewriteRule ^.*\.htm$ /index.html [R=302,L]

But this is adding the document root to the home page path (and also only works for .htm).

Help please!
0
Comment
Question by:PaliTree
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:jeremycrussell
ID: 35513617
Try

RewriteEngine On
RewriteRule ^/.* / [R=302,L]

Open in new window

0
 

Author Comment

by:PaliTree
ID: 35513688
But that redirects everything surely!

I only want to redirect *.htm and *.html. And I DON'T want to redirect index.html to itself!
0
 
LVL 9

Accepted Solution

by:
jeremycrussell earned 500 total points
ID: 35513744
Ah, ok, I see now.  Try:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule ^.*\.ht(m|ml)$ /index.html [R=302,L]

Open in new window

0
 

Author Comment

by:PaliTree
ID: 35513865
That's it!

Thx
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

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 …
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 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