Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
My objective is to write an .htaccess file that redirects all requests to a particular file. This .htaccess file will reside in the top level web root directory.

I've tried this:

Code
RediectMatch .* http://example.com/maint_notice.php


The problem is that it results in a request-loop, with the .php file never getting accessed.

I'd like to change the RedirectMatch so that it redirects all requests except for requests for that file. But I don't know how to write a match pattern that accomplishes this. If there were a "RedirectNotMatch" directive, that would solve the problem.

Any ideas?

Sponsored Links
Joined: Feb 2002
Posts: 2,286
Veteran
Veteran
Joined: Feb 2002
Posts: 2,286
Would it work if you had an
Code
DirectoryIndex maint_notice.php

above the command, and then did a
Code
RedirectMatch ^/$  http://www.example.com

beneath - or would you still hve a loop?

It would work with directing it to a sub-domain, but that may not be an option here.


Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Thanks, but that doesn't seem to have any effect.

By redirecting to a subdomain, do you mean:

RedirectMatch .* http://sub.example.com/maint_notice.php

My hosting account allows creation of subdomains. I think they're implemented as subdirectories under the main directory, so the .htaccess file in the main directory might still get processed, but I can try that.

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
I tried that subdomain approach, but it failed for the above reason.

Joined: Feb 2002
Posts: 2,286
Veteran
Veteran
Joined: Feb 2002
Posts: 2,286
Did you get this one cracked Dave?


Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)
Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Maybe. I'm trying this:

Code
RewriteEngine On <br />RewriteRule maint_notice\.php$ - [L] <br />RewriteRule .* http://example.com/maint_notice.php


The first rule catches requests for maint_notice.php, leaves them alone (replacement string = "-") and then stops processing rules (flag = "L"). The second rule catches anything else.

It seems to work, but I haven't fully tested it yet.

Another possibility was suggested in response to a post I made elsewhere, but I haven't tried it yet:

Code
RewriteEngine On <br />RewriteBase / <br />RewriteRule !^maint_notice\.php$ maint_notice.php [R]


-----
Edit:

Both of the above methods work. I decided to use the second one, since it seems a little simpler.

Last edited by Dave_L; 06/14/2003 11:03 AM.
Joined: Feb 2002
Posts: 2,286
Veteran
Veteran
Joined: Feb 2002
Posts: 2,286
I take it that it didn't work, as the code has gone


Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
It worked, but 6.3 has a bug that strips the [ code ] tag. The bug has been fixed here, so I'll repost the code.

P.S. I posted the fix for the code tag in the Infopop threads bugs forum.

Last edited by Dave_L; 06/14/2003 11:20 AM.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)