Forum Moderators: phranque

Message Too Old, No Replies

accessing root file with htaccess on subdirectory

         

JoaoJose

9:43 am on May 16, 2006 (gmt 0)

10+ Year Member



Hi there.

I've digged for a while and can't find an answer to this.

Having this rule:

RewriteRule ^mypage-([0-9]+)\.html$ /mypage.html?id=$1 [L]

With an htaccess file on a subdirectory how can I access mypage.html?id=$1 on the root of the server?

Thks!

jdMorgan

8:29 pm on May 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By definition, starting the substitution URL with a slash -as you have done-- refers to mypage.html in the Web root directory.

RewriteRule ^mypage-([0-9]+)\.html$ [b]/my[/b]page.html?id=$1 [L]

If you are are trying to go 'above root,' it's not possible using .htaccess because nothing above Web root exists from the HTTP viewpoint. You'd have to use a symlink.

Jim

JoaoJose

7:44 am on May 17, 2006 (gmt 0)

10+ Year Member



Hi Jim.

I think I wasn't clear.

The htaccess file is on a subdirectory and what I want is to get a file on the root of the server, for instance:

By requesting,
home/mysite/www/widget/myrewrite.html

I want the server to return,
home/mysite/www/mypage.html?id=1

The reason for having the htaccess on the subdirectory is because the subdirectory is actually an addon domain and I rather have one htaccess file for each domain than a huge file on root.

I've digged a lot for this and I don't even know if it's doable or maybe it's just not the right aproach to my problem...

jdMorgan

1:43 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> add-on domain.

In that case, the subdirectory *is* the root for that add-on domain, and you cannot 'go higher' using htaccess, because htaccess views your site using 'HTTP rules' of URL-to-filename mapping.

Again, you can use a symlink to link to another file or directory at the *nix level if that would solve your problem.

Jim

JoaoJose

2:55 pm on May 17, 2006 (gmt 0)

10+ Year Member



I see...for that I need shell access right?

Thank you very much for your help

jdMorgan

4:07 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct.

Jim

JoaoJose

9:34 am on May 18, 2006 (gmt 0)

10+ Year Member



Hi again everyone.

My host was pretty swift giving me shell access so I started messing around with symlinks yesterday.

But it's not working and I can't figure why

Here's my code:

ln -s home/client/public_html/ home/client/public_html/site2

After this a request for:

www.site2.com should return the contents of www.site1.com

but it doesn't.

I also tried creating a symlink only for a particular .html file but it also failed.

I then erased .htaccess on /site2 thinking it may be doing some strange redirect, but all the same.

Am I missing something?

Thks!

jdMorgan

9:46 pm on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make sure your symlink 'points' in the right direction, and that the FollowSymLinks option is enabled in the server config or .htaccess.

Jim

JoaoJose

11:24 am on May 20, 2006 (gmt 0)

10+ Year Member



Ok I've found the problem but don't have the solution.

Symlinks work fine but only if I remove

AddHandler application/x-httpd-php .html

from my htaccess.

Any ideas on why this happens and if there is any solution? Offcourse deleting that line from htaccess is not an option...

Thks everyone!

jdMorgan

5:08 pm on May 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know what to make of this, but be aware that you can enclose the Addhandler in a container, and make it conditional depending on URL, directory, etc. Without knowing the exact mechanism of interference, all I can say is that doing so might be useful.

Jim