Forum Moderators: phranque
I have a site I'm automating by making it change every 2 weeks based on the date...
First off the problem originiates from a protected directory. The protected directory is "Members".
When you enter the "Members" directory htaccess determines the month, it then sends you to the directory named 01 thru 12.
When you ender the month directory a new htaccess then determines if it's before or after the 15th of the month and drops you into the directory named A or B.
Now, on these individual pages residing in the A or B directories the file has a PHP include a file from ../../../includes/filename.jpg
NOTE: If you notice above, the includes directory is outside the "members" directory.
The problem I'm having is I have an htaccess file inside the "includes" directory which SHOULD eithe reference the password file for the members directory, OR simply block all hotlinking. I've tried both variants, referencing the htpasswd file and blocking hotlinking.
Doing either one causes the php includes to break on the A and B directories.
The reason I moved the includes directory OUTSIDE the members directory is because I was having this EXACT same problem and figured I could fix it later by using some other kind of htaccess file. The site is done and made with the includes outside the members area and now I still cannot remedy the situation.
What is the problem? Is it because php some how makes requests for includes not using an IP or domain name? Why do I not even get a prompt for password if I reference the htpasswd file? It simply doesn't link it instead of even asking.
Any info on this problem would be helpful.
Thanks in advance.
Welcome to WebmasterWorld!
> Is it because php some how makes requests for includes not using an IP or domain name?
Right. "Include" and "Require" directives, whether in PHP or SSI, are handled inside the server filesystem, and do not use HTTP/TCP/IP transactions, and do not use URLs. Therefore, mod_rewrite has no effect on them. You should provide the actual rooted server filepath to the includes, rather than a relative-to-URL path.
The browser resolves relative URLs (../../something) to canonical URLs (example.com/something), but the browser isn't involved in a PHP include -- It's all done server-side, before the browser gets any response from your server.
I hope this clarifies, rather than confuses... :)
Jim
I just went and looked at my include code and I was mistaken about one part. I'm including from "http://domain.com/includes/dir/file.jpg" not "../../../a"
If I just put in "/home/acct/html/includes/dir/file.jpg" will that work or do I have to make a special include( ) call to specify it's a server path call as opposed to URL?
Thanks in advance!
I've seen this site around but never thought to come here to ask stuff about "webmastering" lol. Usually this site comes up in google searches but I must be a retard of something to have never actually posted here before. LoL!