Author |
Message |
utssace
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/18fec4b5450beb2041ec2.gif)
Joined: Feb 18, 2006
Posts: 155
Location: Virginia
|
Posted:
Sat Oct 13, 2007 3:03 pm |
|
What is the best htaccess code to use to redirect the root to a subfolder.
My site is in a subfolder.
currently I have this:
Code:# Turn on rewrites.
RewriteEngine on
# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
# Only apply to URLs that aren't already under folder.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /subfolder/$1
# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sun Oct 14, 2007 2:33 pm |
|
That should be more than enough. This might well suffice also.
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^(www.)?domain.com [nc]
rewriterule ^(.*)$ http://domain.com/subfolder/$1 [L, nc] |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
utssace
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 14, 2007 7:51 pm |
|
I got an Internal Server error with that code Raven. I am looking
for a simpler code like your suggestion.
The one I posted makes visits to the root domain redirect to the
subfolder but the URL just shows the root domain. However, it also allows
direct access to the subfolder index. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 14, 2007 10:00 pm |
|
Remove this code. Not all hosts let you use it.
Options +FollowSymlinks |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
utssace
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 15, 2007 6:29 am |
|
Strange....even without that first line, I still get a 500 internal server error. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 15, 2007 7:09 am |
|
Hmmm, try this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^(www.)?domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/subfolder/$1 [L] |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
utssace
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 15, 2007 7:37 am |
|
I tried that as well, same error. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue Oct 16, 2007 5:06 am |
|
Maybe this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com/subfolder/$1 [L]
[Edited: I upper cased the HTTP_HOST after-the-fact] |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
utssace
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Oct 16, 2007 6:34 am |
|
The code I posted above works, but for some reason these snippets don't
I noticed the rewrite line looks different from what I posted above. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
utssace
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Oct 21, 2007 8:12 am |
|
A problem that I think may be caused by my use of the redirect code that
I posted above.
Recall that my site is in a subfolder. I am trying to use an htaccess redirect
in the root to point visitors to the site. In my root however, I have other
subfolders with private files in them. When I set password protection for
one the these other folders (using Direct Admin) I keep getting a 403
error when I point my browser to the protected folder. I am prompted
to enter the user/pasword for the folder but afterwards I get the 403 error.
It's the 403.html that is included in my nuke subfolder. I do not have
a 403.html in my root.
I am just wondering if this redirect code it throwing off my call to other folder
in my root.
Any ideas? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|