Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 18th, 2002, 02:41 PM
ucahg ucahg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 4 ucahg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mod_rewrite with subdomains

In my site, I need to have members.sgfcanada.com/XXXX/admin.php -and- URLXXXX/admin.php both point to URLXXXX. I thought the best method to do this would be using the REQUEST_FILENAME variable, since both of the above filename would point to /home/sgfcana/public_html/members/XXXX/admin.php.

Currently, this is my .htaccess file:
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} ^/home/sgfcana/public_html/d([a-z]*)

RewriteRule ^(.*) URL  [QSA,L]

Now, I can go to URL and it works as it should (the correct page shows up). But, when I try to modify the code so it will work inside the members directory, like this:
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} ^/home/sgfcana/public_html/members/([a-z]*)/admin.php

RewriteRule ^(.*) URL  [QSA,L]

then it doesn't work properly (returns a 404 error).

Also, I want it to instead of being lower-case letters and numbers, I want it instead to be and word character(A-Z, a-z, and _ [underscore]) in between 2 and 8 characters long. Any help would be greatly appreciated, for then maybe I'll understand mod_rewrite once and for all

Last edited by ucahg : March 18th, 2002 at 02:47 PM.

Reply With Quote
  #2  
Old March 23rd, 2002, 09:56 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It'd be much more efficient to not use REQUEST_FILENAME because it requires a stat() call. BTW, the default RewriteCond is REQUEST_URI, which can do what you needed.

Reply With Quote
  #3  
Old March 24th, 2002, 07:41 AM
ucahg ucahg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 4 ucahg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow That works, but...

That works thanks

But now I ran into another problem. Here is my .htaccess file now:
Code:
RewriteEngine On
RewriteRule ^(.*)/admin.html backend/admin.php?d=$1 [QSA,L]
RewriteRule ^(.*)/admin.png backend/images/admin.png [L]
RewriteRule ^((.*)/)?siteadmin.php backend/siteadmin.php [L]
RewriteRule ^(.*)/redirect.php backend/redirect.php [L]
RewriteRule ^(.*)/(.*) backend/viewfile.php?d=$1&f=$2


I want the first 4 redirects to go through, and if any of them are matched, stop rewriting (with the [L] tag). All files that do not match those 4 rules go onto the last rule. The problem is, if I go to admin.html, I see viewfile.php instead of admin.php (it's rewriting with the last rule). This shouldn't be the case in my understanding of mod_rewrite, for according to the Apache documentation:
Quote:
'last|L' (last rule)
Stop the rewriting process here and don't apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g., '/e/www/'.

Doesn't that mean if any of the rules are matched, none of the following rules will be carried out?

Thanks for your help,

Reply With Quote
  #4  
Old March 25th, 2002, 02:50 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> if any of them are matched, stop rewriting (with the [L] tag)

Then you don't need to repeat the 2 parameter. Instead, you can specify it to - like so:

RewriteRule ^(.*)/admin.png - [L]

In addition, when you don't specify a RewriteCond, you'd want to specify a leading / like so:

RewriteRule ^/xxx/yyy.ext$ - [L]

>> RewriteRule ^(.*)/(.*) backend/viewfile.php?d=$1&f=$2

Not sure what you are you trying to do exactly. Though specifying ^(.*)/(.*) usually is not reliable and it doesn't always work. Also, you should set /full/system/path/to/backend/viewfile.php?d=$1&f=$2 [T=application/x-httpd-php,L]

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > mod_rewrite with subdomains


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT