LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-22-2009, 04:59 AM   #1
ericcarlson
Member
 
Registered: Jan 2002
Posts: 162

Rep: Reputation: 30
Help with simple Apache RewriteRule please


I'm trying to create a rule which simply says "for all incoming page requests EXCEPT those which begin /templates just send everyone to index.html, otherwise pass through unchanged". Its to manage emergency downtime without taking the whole site offline.

I'm a little green but have read around this and tried this:

RewriteCond %{REQUEST_URI} !^/templates
RewriteRule ^(.*) http://%{HTTP_HOST}/index.html [L]

But with these in force I just get internal server errors.
Must be easy for a pro ;-)
 
Old 05-22-2009, 07:10 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,043

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Well I'm not a pro, but testing your rule, I saw that you need another RewriteCond so you can stop the infinite loop:
Code:
RewriteCond %{REQUEST_URI} !^/templates
RewriteCond %{REQUEST_URI} !^/index.html
RewriteRule ^(.*) http://%{HTTP_HOST}/index.html [L]
Regards
 
Old 05-22-2009, 08:19 AM   #3
ericcarlson
Member
 
Registered: Jan 2002
Posts: 162

Original Poster
Rep: Reputation: 30
Thanks!

Doh!
Yup, after figuring out the syntax I missed the infinite loop. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache RewriteRule does not do what I want? Ujjain Linux - Server 0 03-26-2009 07:46 AM
Rewriterule problems apache 2.2.4 qwqg Linux - Server 7 03-21-2008 04:20 AM
Apache rewriterule mesh2005 Linux - Server 1 08-03-2007 02:23 AM
Help w/ Apache htaccess (RewriteRule) bhuwan Programming 1 03-16-2006 06:06 AM
Apache RewriteRule is driving me nuts ijsman77 Linux - Software 3 04-07-2004 02:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration