The Cellar  

Go Back   The Cellar > Main > The Internet
FAQ Community Calendar Today's Posts Search

The Internet Web sites, web development, email, chat, bandwidth, the net and society

Reply
 
Thread Tools Display Modes
Old 11-12-2005, 07:07 AM   #1
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Apache question (technical)

I'm playing around with Forcetype in an effort to clean up URLs, all well and good, I want it so that for example:
domain.com/type/item
gets echoed back to domain.com/index.php with the $vars type and item.

So far I've got a file called type that is a php file and is recognised as such, all well and good, all I need to do now is include index.php and we're cooking with gas.

This is where is gets odd. PHP thinks it's inside a dir called log, which of course doesn't actually exist and thus " require'index.php'; " craps out, as does " require'../index.php' ". There are plenty of tutorials out there on ForceType but none seem to deal with this issue of including files.

I've tried creating an absolute URL from $_SERVER['DOCUMENT_ROOT'] and adding the php but that was no good either.

Ideas?
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Old 11-12-2005, 09:31 AM   #2
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
Why does it think it's in log? Do you get an error message saying log/index.php doesn't exist?
Undertoad is offline   Reply With Quote
Old 11-12-2005, 09:43 AM   #3
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
yup, to be exact:
Warning: main(index.php): failed to open stream: No such file or directory in /xxx/xxx/public_html/log on line 12
Fatal error: main(): Failed opening required 'index.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /xxx/xxx/public_html/log on line 12

Exactly why it thinks it's in a dir called log is beyond me.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain

Last edited by jaguar; 11-12-2005 at 09:46 AM.
jaguar is offline   Reply With Quote
Old 11-12-2005, 09:48 AM   #4
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
Weird. Are you actually in public_html? Are there any .htaccess files changing things? Is there actually a directory public_html/log?
Undertoad is offline   Reply With Quote
Old 11-12-2005, 11:00 AM   #5
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
There's no DIR called log, just the php file with no extension which is in public_html. I've put the relevent bit .htaccess below, the rest is just auth.
Code:
(Files log)    
	ForceType application/x-httpd-php
(/Files)
Brackets instead of angle brackets because the forum soft keeps taking them out, even when I put in code
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain

Last edited by jaguar; 11-12-2005 at 11:04 AM.
jaguar is offline   Reply With Quote
Old 11-12-2005, 11:58 AM   #6
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
I don't think ForceType is what you want to use to do this. It seems ForceType is demanding a file named log, to be interpreted as a PHP file and living in /type.

I think you want to use URL rewriting. But URL rewriting is hard, and every time I look at the reference page I get a massive headache.
Undertoad is offline   Reply With Quote
Old 11-12-2005, 02:20 PM   #7
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Quote:
...and living in /type.
I don't understand that last bit.

URl rewriting is the other way of doing this but I get a headache too and every time I try it I just get Internal Server errors.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Old 11-12-2005, 02:34 PM   #8
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
Try this in the .htaccess of the base directory - this is just a guess, but:

RewriteEngine On
RewriteRule /(.+)\/(.+) ?type=$1&item=$2

Are there ANY directories in the root directory? You wouldn't be able to get to them...
Undertoad is offline   Reply With Quote
Old 11-12-2005, 02:41 PM   #9
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
need to access dirs, I'm going to take this golden opportunity to learn regular expressions and take occasional breaks with a punching bag.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Old 11-12-2005, 02:46 PM   #10
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
URL Rewrite will only be a decent solution if both "type" and "item" are uniform in some way - like, if they're both numbers, or a letter followed by a number, something you can identify that won't aloso identify the other directory names.

What I was trying to do was to capture the type (in-between slashes) and item, because in regular expressions, anything in parentheses gets "saved" as $1, $2 etc. Then once they are saved, use them to build a new URL address.

I should have used .* instead of .+

URL Rewrite is magical and scary. Regular expressions are sexy once you know them.
Undertoad is offline   Reply With Quote
Old 11-12-2005, 02:47 PM   #11
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
it's gonnabe something like..
RewriteRule ^log/([0-9]+)/$ index.php?page=log&id=$1

that one is giving me 404 errors but I can't be that far off.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain

Last edited by jaguar; 11-12-2005 at 02:49 PM.
jaguar is offline   Reply With Quote
Old 11-12-2005, 02:49 PM   #12
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
Nice. (Does the URL always have the preceding slash though?)
Undertoad is offline   Reply With Quote
Old 11-12-2005, 02:50 PM   #13
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
I'm adding a second line to deal with that when I get it working at all.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Old 11-12-2005, 02:59 PM   #14
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Well.
That works. Except for two odd problems, one the result of the other.

RewriteRule ^log/([0-9]+)/$ index.php?page=log&id=$1
Works fine but all links in index.php to stylesheets etc get broken.

RewriteRule ^log/([0-9]+)/$ index.php?page=log&id=$1 [R]
Works but puts the entire dir structure from server root in front of the domain:
http://www.xxx.xxx/xxx/xxx/public_ht...?page=log&id=1
Thoughts?
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Old 11-12-2005, 03:09 PM   #15
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Interestingly I got PHP to echo its location back, it says exactly the same either way so I'm stumped.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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 On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 10:59 AM.


Powered by: vBulletin Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.