|
#1
|
||||
|
||||
|
I am moving a web site from another server to an addon domain on my HG account. I have successfully created an addon domain and have changed the DNS settings for the second web site. However, .htaccess file in the root directory is affecting the web site in the addon directory. I have special rewrite rules in the root .htaccess file for that website. I know that .htaccess files are global and affect subdirectories, but in this case I do not want the root .htaccess file to affect the addon directory. What happens right now is that www.eagledatainc.com (the addon directory, in public_html/eagledatainc) gets forwarded to www.turkishenglish.com (the root directory).
I tried the following directive, but it did not work: ReWriteRule ^eagledatainc/.*$ - [L,R=301] I am trying to write a rule at the top that will catch hits to the subdirectory and stop the substitution. Here is the relevant part of the .htaccess file in the root directory: DirectoryIndex root.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(en|tr)/?$ root.php?language=$1 [QSA,L] RewriteRule ^(en|tr)/([-A-Za-z0-9_.]+)\.html$ root.php?language=$1§ion=$2 [QSA,L] RewriteRule ^(en|tr)/member\.php$ member.php?language=$1 [QSA,L] RewriteRule ^administrator/?$ admin.php [QSA,L] RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule ^(.*)$ hack.php [L] #ErrorDocument 404 /test/404.php Any help would be greatly appreciated. |
|
#2
|
||||
|
||||
|
If you don't need any rewriting in the subdirectory, what about putting this line in your subdirectory's .htaccess:
RewriteEngine Off
__________________
Follow me on Twitter! http://twitter.com/mrw |
|
#3
|
||||
|
||||
|
Thanks for the suggestion, but I tried it and it didn't work. In fact the .htaccess in the subdirectory seems to be ignored. If I delete .htaccess in the root directory, then my website in the subdirectory works. In other words, I think the the server is processing .htaccess in the root directory before it looks at .htaccess in the subdirectory, even thought it's an addon domain and (I think) it should just look at the files in the subdirectory!
|
|
#4
|
||||
|
||||
|
This may not help, I realize, but I have the same basic setup as you do.
That said, in my subdomain root the .htaccess file overrides the permissions/restrictions in the main domain's .htaccess file. BUT, any restriction and/or permission in the root domain's .htaccess, must be explicitly overridden by the subdomain's .htaccess, by using the same command and "toggling" the setting as necessary. Disclaimer: That may not be a COMPLETE answer, but it's what I've found to be the case in MY setup. RV |
|
#5
|
||||
|
||||
|
Hey thanks a lot for replying. However, it doesn't work in my case. As a test, if I delete the .htaccess in the public_html root, then the web site in the subdirectory works correctly! I am going to try to raise this issue with support and see if they can help.
Thanks |
|
#6
|
||||
|
||||
|
FYI, I just figured it out. RV, your advice did work after all! I had some other redirects in my .htaccess file in the root directory (I didn't post them because I thought they were irrelevant.) I decided to simplify things and found out that you are right about commands in the .htaccess overriding if you issue the same command in the opposite direction. Slapshotw, Your first suggestion of just turning off the rewrite engine worked after all!
Thanks a bunch! Last edited by paradigm; 05-27-2008 at 08:40 AM. |
|
#7
|
||||
|
||||
|
For anyone who is interested, I finally found the relevant portion in the Apache tutorial:
The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof. However, it is important to also remember that there may have been .htaccess files in directories higher up. Directives are applied in the order that they are found. Therefore, a .htaccess file in a particular directory may override directives found in .htaccess files found higher up in the directory tree. And those, in turn, may have overridden directives found yet higher up, or in the main server configuration file itself. (http://httpd.apache.org/docs/2.0/howto/htaccess.html) |
|
#8
|
||||
|
||||
|
You're welcome. Glad I could help.
It mystified me, too, until Support (here, I think, may have been my reseller elsewhere) told me about the "flow-down" into subdirectories, regardless of whether that subdirectory was itself a Subdomain. RV |
|
#9
|
||||
|
||||
|
The use of .htaccess files can be disabled completely by setting the AllowOverride directive to none:
Code:
AllowOverride None |
|
#10
|
|||
|
|||
|
Quote:
/path/to/subdir/.htaccess: AllowOverride not allowed here Any suggestions? This directive inheritance is killing me right now! |
|
#11
|
||||
|
||||
|
AllowOver is not useable in a .htaccess file, you can only use it in <Directory> and no place else. You could try something like RewriteCond %{REQUEST_URI} !subdomain.com or maybe the %{THE_REQUEST} would be better.
__________________
“There is a principle which is a bar against all information, which is proof against all arguments and which cannot fail to keep a man in everlasting ignorance—that principle is contempt prior to investigation.” —Herbert Spencer
|
|
#12
|
|||
|
|||
|
Quote:
I have about 20 RedirectPermanent lines in my root htaccess file, for redirecting only SOME .html files to their .php replacement, which are being inherited by the subdom one directory path lower (/subdomain). Unfortunately the subdomain and the root domain contain like-named files and this is causing redirects from subdomain.com/test.html to root.com/test.php. HG support recommended I start with a fresh htaccess file, replacing individual RedirectPermanent lines with individual RewriteRule lines. Again, note that I am not redirecting ALL .html to .php - that would be much more simple. What's more, Apache documentation recommends using Redirect for per-file use rather than RewriteRule but I don't suppose they figured this would happen. I have not yet found a way to rewrite just some files of the root all while not touching the subdom...
|
|
#13
|
|||
|
|||
|
ok, I fixed it. I need to finish editing before I post the fix...
|
|
#14
|
|||
|
|||
|
Here's what worked:
#enable rewrite engine RewriteEngine on #rewrite to root path RewriteBase / #Following line is the old method #RedirectPermanent /about.html http://www.root.com/about.php #Following line is the new method RewriteRule ^about\.html$ about.php [R,L] ____ EOF ____ .htaccess file in subdomain path (/public_html/subdomain.com/) looks like this: RewriteEngine off ___ EOF ___ That's it! It was irritating because I would make a change to the htaccess and it would work, then stop working later without making any new changes. Finally I realized that there was something with Firefox caching or something, because it worked fine in IE which hadn't been to either site before. |
|
#15
|
|||
|
|||
|
One thing that can really simplify this whole mess is to create your subdomains/add-on domains in a directory above public_html/
This also prevents people from accessing your subdomain/add-on domain through your main domain. Example: example.com/mysubdomain or example.com/myaddondomain |
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Addon Domain Problem | Tayrak | Shared Hosting Support | 10 | 05-21-2008 09:32 AM |
| Redirect an addon domain to another addon domain? | kitandpup | Pre-Sales Questions | 1 | 04-17-2008 05:45 PM |
| subdomain of addon domain in addon directory, is it possible ? | Hadoken | Shared Hosting Support | 16 | 03-16-2008 06:39 AM |
| rewrite / .htaccess problem | gobezu | Shared Hosting Support | 1 | 03-18-2007 12:24 PM |
| Addon domain problem, should I wait 24-48 hours before adding new domain? | osakka | Shared Hosting Support | 1 | 10-01-2006 08:12 PM |
All times are GMT -5. The time now is 07:59 AM.










