The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 09:10:08 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: mod rewrite n00b question  (Read 2903 times)
freedom1972
Rookie
**
Offline Offline

Posts: 17


View Profile
« on: February 16, 2008, 02:50:50 PM »

trying to mimic a deep directory strucutre so I can redirct subdomain.myurl.com/a/b/c/d/e.html to subdomain.myurl.com?index.php?foo=a&bar=b etc...

I was doing some simple testing with apache, but am running into this problem

RewriteEngine on

RewriteCond ^/(.*)/%{REQUEST_FILENAME} !-f
RewriteRule .* /index.php [L]

RewriteCond ^/%{REQUEST_FILENAME} !-d
RewriteRule .* ./index.php [L]

RewriteEngine Off


what I wanted to happen was this:

if I requested subdomain.myurl.com/foo/bar.html the first rule will fire, and if I requested subdomain.myurl.com/foo/ the second rule would fire. Instead I get

The requested URL /foo/bar.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

which to me looks like it is trying to use the error handling in the .htaccess file in the myurl.com as opposed to subdomain.myurl.com.

So:

1) is my mod_rewrite syntax correct?
2) do I need to "force" it to use my subdomain .htaccess for error handling over the parent
Logged

No links in signatures please
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #1 on: February 16, 2008, 06:48:26 PM »

/foo/bar.html does not actually exist, correct?  This is an example "fake" URL, right?

So, the request is not being matched by either of your directives.

If the syntax is not correct you will get  Internal Server Error.

wish i could say more, but breakfast is being served Cheesy
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #2 on: February 16, 2008, 08:28:57 PM »

btw,

REQUEST_FILENAME
    The full local filesystem path to the file or script matching the request.


you sure that's what you want?

i usually use REQUEST_URI

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: February 16, 2008, 09:22:46 PM »

yah, ummm...

this works for me


RewriteCond %{REQUEST_URI} (/.*/?)
RewriteRule (.*) homepage.cgi [L]


Then I have my perl script do: 
Code:
print "REQUEST_URI: $ENV{REQUEST_URI}<br>";


clinically tested.

Cheesy
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
freedom1972
Rookie
**
Offline Offline

Posts: 17


View Profile
« Reply #4 on: February 17, 2008, 05:15:09 PM »

thanks - I will try the above and see if that gets me what I am going after.
Logged

No links in signatures please
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!