Need some htaccess URL rewriting help

I have the following in my .htaccess file (minus that “1.”, which I have no idea why that was added because I used the code block to insert the htaccess code–which is what I thought I needed to do?):


[LIST=1]
[*]RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^127\\.0\\.0\\.1
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.147
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.83
RewriteCond %{REQUEST_URI} !/projects/abc_wiki$  
 
RewriteRule .* /projects/calendar.abc.edu [R=302,L]
rewritecond %{http_host} ^localhost.abc.edu [nc]
rewriteRule ^(.*)$ http://localhost:8080/www/projects/calendar.abc.edu/$1 [r=301,nc] 
[/LIST]
 

I’m not sure how to exactly word this, so bear with me here…

I need to make my browser forward localhost.calendar.edu to 127.0.0.1 where I have WAMP and UltiDev running to handle both PHP and ASP stuff. This, I have working… But how can I make all “localhost.calendar.edu” browser requests be forwarded to the sub-directory of “www/projects/calendar.abc.edu” and make that sub-directory appear to have localhost.calendar.edu as its domain name? So for example, if I’m on my workstation browsing to www/index.php, the domain name would probably be something like “http://localhost/index.php”, but what I want to do is have “http://localhost.calendar.edu” when I’m browsing for “localhost.calendar.edu” from within www/projects/calendar.abc.edu. (I’m trying to set my sub-directory to use its own exclusive domain, but I’m not sure if this is being worded correctly to explain what I’m trying to do here.)

In my HOSTS file, I have “localhost.calendar.edu” assigned to 127.0.0.1, so now whenever I travel to localhost.calendar.edu, I at least get forwarded to my www root. This is correct: I can see my domain in the address bar and everything is working. But now I need to do something with .htaccess. I think it’s called a “rewrite” (and not a redirect) despite Firefox telling me that the redirect will never succeed–for reasons I can’t understand yet. I think a problem to consider here with this is how Apache will offload the request into :8080, which is being handled by UltiDev (the ASP server I have running).

(My understanding of .htaccess code / syntax isn’t that great, so any input / insight into what I’m trying to do here is very appreciated.)

Note: The reason I’m trying to do all this is because I’m working on some legacy ASP installations and I’m just trying to test for specific domain names in my scripts. I’m trying to build a file-level process to handle specific URL requests. I’m working on something IIS-related from a production environment that has forced us to resort to this approach due to how various virtual directories / bindings have been configured through IIS–which I despise, FWIW. :slight_smile:

Sorry everyone, but I think I got it figured out (feel free to provide any additional insight if you want or if you see anything wrong with the following):

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^127\\.0\\.0\\.1
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.147
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.83
RewriteCond %{REQUEST_URI} !/projects/abc_wiki$  

RewriteCond %{HTTP_HOST} ^localhost.calendar.edu$
RewriteCond %{REQUEST_URI} !^/projects/calendar.abc.edu/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /projects/calendar.abc.edu/$1
RewriteCond %{HTTP_HOST} ^localhost.calendar.edu$
RewriteRule ^(/)?$ projects/calendar.abc.edu/ [L]

Btw, I use the first RewriteConds to redirect clients to an informational site I have setup on my localhost. I don’t open up my entire computer to everyone (for obvious reasons) but it’s nice to provide static information about things from time-to-time (which is what those are for–I needed to allow them to access that specific directory alone–which I hope isn’t impaired now by what I’ve done with this sub-directory stuff).

W_22,

If possible, I’d send your “visitors” to another link after their checks (OR use a Switch flag to circumvent the other code - use the digits for the number of RewriteRules to skip).

Coding concerns (as usual):

RewriteEngine On
[COLOR="#808080"]RewriteBase /
# WHY?[/COLOR]
RewriteCond %{REMOTE_ADDR} !^127\\.0\\.0\\.1
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.147
RewriteCond %{REMOTE_ADDR} !^149\\.102\\.45\\.83
RewriteCond %{REQUEST_URI} ![COLOR="#FF0000"]/[/COLOR]projects/abc_wiki$
[COLOR="#FF0000"]# Will only match with Apache 1.x[/COLOR]

RewriteCond %{HTTP_HOST} ^localhost.calendar.edu$
RewriteCond %{REQUEST_URI} !^[COLOR="#FF0000"]/[/COLOR]projects/calendar.abc.edu/
[COLOR="#FF0000"]Ditto[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /projects/calendar.abc.edu/$1
RewriteCond %{HTTP_HOST} ^localhost.calendar.edu$
RewriteRule ^[COLOR="#800080"](/)?[/COLOR]$ projects/calendar.abc.edu/ [L]
[COLOR="#800080"]# What's this for? With the $, you're only looking at the DocumentRoot.[/COLOR]

Regards

DK