Forum Moderators: phranque

Message Too Old, No Replies

Manipulate folders with htaccess

         

HappyCoder

9:05 am on May 2, 2012 (gmt 0)

10+ Year Member



Hello,

I use the cPanel platform. I point all domains into the folder
/home/hc/public_html/domain/
In the "domain"-folder I call a PHP-file via htaccess that find the exact file-folder in MySQL.

A hypothetical example:
1) mydomain.com pointing into /home/hc/public_html/domain/
2) htaccess calls a PHP-file in the "domain" folder and find mydomain.com in MySQL.
3) MySQL returns "/home/hc/public_html/www.mydomain.com/" (which is the exact file-folder mydomain.com).
4) I would like to have htaccess or PHP to understand that it (programmatically) to create the root folder on to be "/home/hc/public_html/www.mydomain.com/" instead of "/home/hc/public_html/domain/"

I've tried about 5745872348 different combinations without finding the right one, so now I ask for help.

Keep my happy :-)
HappyCoder

g1smd

10:04 am on May 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What have you tried, so we can point out where you went wrong?

HappyCoder

11:36 am on May 2, 2012 (gmt 0)

10+ Year Member



I've tried with this code in htaccess:
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{REQUEST_URI} !^/home/hc/public_html/www.mydomain.dk/www/
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /home/hc/public_html/www.mydomain.dk/www/$1

But the result is that the page can not be displayed.

I've also tried with PHP (without htaccess), but I have trouble viewing the images, css files and javascript files.
In PHP I have tried both with readfile() and include().
Images, javascript files and css files do I not settled properly when I do it that way.

lucy24

8:52 pm on May 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Unless there is something seriously wrong with either your DNS or with cPanel, the /home/blahblah/ part of the path should never be visible to anyone. It may show up in your error logs, but nowhere else. Everything starts from your domain name and works downward.

If you simply request your domain in the usual way

http://www.example.dk

what do you get?

What if you request something that doesn't exist, like

http://www.example.dk/fejltryk.html

Those are your starter questions.

You must use example.com (or example.dk or example.bzzt et cetera) to prevent your text from turning into a clickable link that people can't read.