View Full Version : how to make redirect code work in the .htaccess
Hi ,
I made a subdomain sale.bishoy.com
It works but the problem is : the redirect code (for making the images appear) is not working .
I created a directory /sale/images and put one copy of it in the htdocs and one another copy above the htdocs (which one is the correct?)
My .htaccess file code in the htdocs:
Redirect /sale/images http://www.bishoy.com/images
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName bishoy.com
AuthUserFile /www/b/bishoy/htdocs/_vti_pvt/service.pwd
AuthGroupFile /www/b/bishoy/htdocs/_vti_pvt/service.grp
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} sale.bishoy.com
RewriteCond %{REQUEST_URI} !eng/pc2phone/index.htm
RewriteRule ^(.*)$ eng/pc2phone/index.htm$1 [L]
ErrorDocument 404 http://www.bishoy.com/eng/errors/404.htm
never create directories below the htodocs. You can find help from the help.powweb.com/tutorials/
I have printed out all the tutorials , they are before my eyes continously .
How do you say " never create directories below the htodocs "?
I copied and pasted the url and no.i of Sharing Files with Sub Domains
http://help.powweb.com/tutorials/htaccess/subdomain.php
Sharing Files with Sub Domains
Please note that:
1) http://www.yoursite.com/subfolder/
is different from
2) http://subfolder.yoursite.com/
In fact if you have a link to an image (which calls /htdocs/images/) it will only show in link 1 but NOT in link 2. If you would like to share your files (such as the images) in your sub domains then the following procedure must be made:
i. Create a directory /subfolder/images
That part is necessary when you need to do as follows:
http://www.domain.com/images/image.jpg
you cannot access it like this subdomain.domain.com/images/image.jpg unless you do as per tutorial.
when it says to create a directory /subfolder/images you should always create it above the htdocs.
Although I created a directory /sale/images above the htdocs ,
the pictures do not appear in the url http://sale.bishoy.com
my code of .htaccess of htdocs is written the first post
You have Fp extentions installed and these might cause some problems. Code seems to be fine.
RSaucier
9-21-02, 02:18 PM
I think there's a semantics problem here :). If you think of it as a vertical organizational chart with the root directory at the top, it makes it easier.
Since extra spaces get stripped out, it's difficult to show here but:
........................................root
.........................................|
..................................+------+----------------+--------+
..................................|............... ........|........|
.................................www.............. .......usr......etc
..................................|
......................+-----------+------------+
......................|........................|
......................a........................b
......................|
............+---------+---------+
............|...................|
.........accounta............accountb
............|...................|
......+-----+-----+.......+-----+-----+
......|.....|.....|.......|.....|.....|
....htdocs.etc.cgi-bin..htdocs.etc.cgi-bin
......|
...+-----+
...|.....|
images.forum
So, to me:
"Above" htdocs refers to the same level as or "higher":
/www/a/accounta/cgi-bin = above (really a "peer" since it's at the same level)
/www/a = above
/www/a/accounta/etc = peer
"Below" would refer to something contained in:
/www/a/accounta/htdocs/images = below
Does that help, bishoy?
I am very glad with your chart and will print it , but please give more description as I fear , I don't understand the description .
Very very great thanks to you
RSaucier
9-21-02, 02:34 PM
I apologize, I don't understand what you need but ...
The chart represents a "typical" setup.
Let's call:
/www/a/accountname your "account root" and
/www/a/accountname/htdocs your "web root" and
/www/a/accountname/cgi-bin your "cgi root"
Anything requiring a redirect entry in a .htaccess file will need to go either in the web root or the cgi root (or subdirectories within those directories).
Files that are in your account root or subdirectories (that are NOT your web or cgi root directories) are not directly accessible from your website.
Does that help at all?
I put the /subfolder/images in the same level of htdocs
.........accounta
............|
......+-----+-----+----------+
......|.....|.....|.......|...........|
....htdocs.etc.cgi-bin.subfolder(sale)
......|................................|
...+-----+..........................+
...|.....|..............................|
images.forum...............images
RSaucier
9-21-02, 02:41 PM
The subfolder will have to be created in the htdocs directory if you want to redirect a subdomain to it:
/www/a/accountname/htdocs/subfolder
The .htaccess file to perform the redirect will go in the htdocs directory.
You are right ,
my subfolder sale.bishoy.com goes to my page http://bishoy.com/eng/pc2phone/index.htm
the subdomain is working , but the pictures do not appear.
I created a directory /sale/images and put one copy of it in the htdocs and one another copy above the htdocs(as in my chart) to redirect the images to the new subfolder
but nmsupplies said in this thread "never create directories below the htodocs"
also "create a directory /subfolder/images you should always create it above the htdocs."
I still think that your problem is the fp extensions. What you are doing in the tutorials has been submitted by users and tested by myself (in most cases). That part of the tutorial was a 4 day brian crushing between me and another user who had this problem and finally managed to solve the problem.
When I say above htdocs it means:
/htdocs/subfolder
Nothing below the htdocs will be recognised with html (of course cgi-bin is also at a higher level). In fact when we place something below the htdoocs this can only be accessed by /www/u/username/file.htm
RSaucier
9-21-02, 03:45 PM
:) that's where I meant when I said there was a problem with semantics.
Neville, to you, "above" means within htdocs. Bishoy associates it with /www/a/accountname.
I admit that I take "above" to mean "higher in the heirarchy" i.e. /www/a/accountname.
I didn't mean to step on your toes, Neville. I'll back out of the thread.
Come on RSaucier, you did not step on my toes....we are all here to help users. As long as help is not repetative nor stupid I accept all interuptions and posting to all the threads in this forum including those that I am answering.
This is not a battle to help ... We just want to help...when I switch on my PC, someone else must continue and I don't mind at all.
I read your posts and I like them...your 1000 (near) posts have some sense and the answers have real content.
:)
RSaucier
9-21-02, 05:21 PM
Glad there was no offense!
It sometimes gets confusing if there are too many cooks stirring the pot, so to speak. That's why I offered to back out. :)
Upward and onward! Bishoy, did you get your problem solved?
Now I put the /subfolder/images below htdocs
.........accounta
............|
......+---------+--------+
......|.............|...........|
....htdocs....etc.....cgi-bin.
......|
...+----------+--------------------+
...|..............|............................|
images.....forum..............subfolder(sale)
...............................................|
..............................................imag es
But the frontpage extensions are queued to be uninstalled for 6 hours up till now .. and the pictures of sale.bishoy.com accordingly can not appear .
Once the extensions uninstalled , I will test again and tell you .
I removed extensions still no pictures appear and my .htaccess code now is
Redirect /sale/images http://www.bishoy.com/images
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} sale.bishoy.com
RewriteCond %{REQUEST_URI} !eng/pc2phone/index.htm
RewriteRule ^(.*)$ eng/pc2phone/index.htm$1 [L]
ErrorDocument 404 http://www.bishoy.com/eng/errors/404.htm
you are pointing the subdomain to a file not to a folder. The redirection for that subdomain is useless!
Now
1- my frontpage extensions are not installed
2- I pointed the subdomain to a folder not a file
3- I cleared my cache many times (deleting cookies)
4- There is a folder named sale below the htdocs , another folder named images below the folder sale
......htdocs....cgi-bin....etc
..........|
.....----------
.....|...........|
...sale
.....|
.images
5- uploaded the .htaccess as .htaccess.txt then renamed it on server to .htaccess
6- My .htaccess file code
Redirect /sale/images http://www.bishoy.com/images
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} sale.bishoy.com
RewriteCond %{REQUEST_URI} !eng/pc2phone/
RewriteRule ^(.*)$ eng/pc2phone/$1 [L]
ErrorDocument 404 http://www.bishoy.com/eng/errors/404.htm
:confused: still pictures don't appear in sale.bishoy.com
although they appear in bishoy.com/eng/pc2phone/
SimCoWeb
9-26-02, 03:17 AM
hehe....all this work to have 'something.mysite.com' work. Is it really that important or would it be easier to just have 'www.mysite.com/something' ?? :)
If you have a folder (ie: /sale/images) 'below' your /htdocs then it's not viewable by the public. The /htdocs folder is the public folder. However, you can call info from the 'root' folders and even write data to those folders.
You would be better off placing the images in the /htdocs folder as /htdocs/sale/images and make the path to that location in your .htaccess file.
RamjetFDO
9-26-02, 08:40 AM
Just for grins... try moving
Redirect /sale/images http://www.bishoy.com/images
after the lines in .htaccess that actually define your subdomain.
There may be a problem with the order in which your .htaccess is being parsed and you're defining a "Redirect" on a subdomain that hasn't been defined yet?
It's just my $0.02... it may not be the problem at all...
Roger
RamjetFDO
9-26-02, 08:49 AM
Bishoy --
For some reason, I can't seem to view your HTML source. Exactly *HOW* are you referencing your images? Please post your exact source <IMG> tags here. That will help out with exactly what you need to put in your Redirect tags...
Oh... and I know you didn't ask for it, but I HATE it when websites pseudo-maximize themselves without asking.... and what's with moving the scrollbar to the *left* side of the window? Usually, you need a pretty good reason for going "non-standard" like that... what is it?
Roger
Hi Sir SimCoWeb
About having something.mydomain.com , I am eager to do it .
If you looked to my chart in the last post in 09-26-02 06:33 AM
you would see that I put the folder sale after the htdocs like /htdocs/sale/images , you can enter the following url to be sure http://bishoy.com/sale/
I made the redirect to /htdocs/sale/images and now .htaccess code is :
Redirect /htdocs/sale/images http://www.bishoy.com/images
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} sale.bishoy.com
RewriteCond %{REQUEST_URI} !eng/pc2phone/
RewriteRule ^(.*)$ eng/pc2phone/$1 [L]
ErrorDocument 404 http://www.bishoy.com/eng/errors/404.htm
All that and still pictures do not appear in http://sale.bishoy.com
Although they appear in http://bishoy.com/eng/pc2phone
RamjetFDO
9-26-02, 12:04 PM
I think I'm starting to understand this one...
You have http://sale.bishoy.com/ as a defined subdomain which should be equivalent to http://bishoy.com/eng/pc2phone/, right?
In your HTML, you have (trimmed down)
<img src="../../images/pc2phone/callworld.jpg"...
If you note, this should resolve to /htdocs/images/pc2phone/callworld.jpg, right?
HOWEVER... your .htaccess file wants to transfer /htdocs/sale/images.
You have no need for a "/htdocs/sale" directory, do you??
Since you've redirected "sale.bishoy.com" to "/htdocs/eng/pc2phone/", you probably want your Redirect to look like:
Redirect /eng/pc2phone/images http://www.bishoy.com/images
Remember, you don't put "/htdocs" on the Redirect (as it already knows you're there!). Since your "sale.bishoy.com" subdomain redefines the "root" to be in /htdocs/eng/pc2phone, none of your "double-dot" references will ever go above that... so... your IMG tag above will resolve to /htdocs/eng/pc2phone/images, which isn't what you want.
Try the Redirect example I have above... let me know if that works or not.
Roger
I wrote your code and it worked excellently , many many thanks , you are genius .
About the scrollbar , I promise you to adjust it , but I needs some work to prevent mirroring of the page and I am very busy nowadays as I have my final year faculty exams so near .
I don't pseudo-maximize my site , I only want to keep privacy of my folders so that contents won't be at all public . In near future I will separate private and shared files .
RamjetFDO
9-27-02, 02:28 PM
I wrote your code and it worked excellently , many many thanks , you are genius .
My pleasure. :D
Regards,
Roger
RamjetFDO
9-27-02, 05:35 PM
I don't pseudo-maximize my site...
Actually... you do:
<script language="JavaScript1.2">
<!--
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.avail Height);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
I hate sites that do this. <g>
Roger
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.