Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13

    Wrong website loaded when other requested


    superhost.gr (loads ok)

    superhost.gr/~dauwin (instead of loading that website it also loads superhost.gr)

    The above is: /home/dauwin/public_html/.htaccess

    RewriteEngine Off
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^/?(.+\.html) /cgi-bin/metrites.py?htmlpage=%{REQUEST_FILENAME} [L,PT,QSA]


    Any ideas why this redirections happens by mistake? (if its a redirection)
    When i turn off the engone the correct website appears.
    What is now proved was once only imagined!
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    So /~dauwin shouldn't work?

    Seems like you have mod_userdir enabled.
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    Originally Posted by requinix
    So /~dauwin shouldn't work?

    Seems like you have mod_userdir enabled.

    Can tou be more specific please?
    Its onlt when i enable .htaccess engine on that this happens.
    it i turn it off it doesnt.

    Wha shoulg i change?
    What is now proved was once only imagined!
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    If you turn off .htaccesses entirely then your site won't work so I'm not sure what you're saying.

    mod_userdir. Is it enabled?
  8. #5
  9. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    we are talkign about
    the .htaccess file located at /home/dauwin/www/.htaccess.

    The only way for this websites to be able to laod is only if i turn the engine off:

    RewriteEngine Off
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^/?(.+\.html) /cgi-bin/metrites.py?htmlpage=%{REQUEST_FILENAME} [L,PT,QSA]

    I wrote those directievs to be able to send html templates to be handled by my pythn cgi script.

    foe some reason though when i enable the engine instead of
    superhost.gr/~dauwin to load

    superhost.gr loads.....

    i dont kmnow if mod_userdir is anbled. how cna i check it? are you sure this is relevant?
    What is now proved was once only imagined!
  10. #6
  11. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Your index page is index.html. Going to http://superhost.gr/ will load /index.html. Going to http://superhost.gr/~dauwin/ (when that does work) will load /~dauwin/index.html. I'm pretty sure those are the same two files.

    I'm now confused as to exactly when the two "websites" "work". So I'm going to ignore that for a minute.

    Your Apache is configured to load modules somehow. Maybe an Include for each one, maybe one for an entire directory, maybe something else. I don't know. Look at how the module loading happens and tell whether mod_userdir is one of them being loaded.
  12. #7
  13. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    I can show you httpd.conf if you like. all websites load okey.

    look
    superhost.gr = /home/nikos/www/index.html

    and

    superhost.gr/~dauwin = /home/dauwin/www/index.html

    Those are 2 different websites
    i will turn the engine of for you to see this.

    Code:
    RewriteEngine Off
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^/?(.+\.html) /cgi-bin/metrites.py?htmlpage=%{REQUEST_FILENAME} [L,PT,QSA]
    Now you will be able to see that indeed are 2 different webpages.
    if i enable back the engine then when i browse superhost.gr/~dauwin then superhost.gr is appearing.

    But why thoese fiels are under 2 different usernames and cPanel accounts....
    What is now proved was once only imagined!
  14. #8
  15. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Code:
    http://superhost.gr/cgi-bin/metrites.py?htmlpage=/home/dauwin/www/index.html
    gives the homepage. In fact substituting anything for the htmlpage variable gives the homepage, even for
    Code:
    http://superhost.gr/cgi-bin/metrites.py?htmlpage=/today/is/sunday
    files that I can only assume don't exist.

    What does your metrites.py script look like?
  16. #9
  17. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    Originally Posted by requinix
    Code:
    http://superhost.gr/cgi-bin/metrites.py?htmlpage=/home/dauwin/www/index.html
    gives the homepage. In fact substituting anything for the htmlpage variable gives the homepage, even for
    Code:
    http://superhost.gr/cgi-bin/metrites.py?htmlpage=/today/is/sunday
    files that I can only assume don't exist.

    What does your metrites.py script look like?
    Code:
    page = form.getvalue('page') or form.getvalue('htmlpage')
    
    # detect how 'index.html' is called and validate variables 'htmlpage' && 'page'
    if page and os.path.isfile( '/home/nikos/public_html/cgi-bin/' + page ):
    	page = page
    elif form.getvalue('show') and os.path.isfile( page ):
    	page = page.replace( '/home/nikos/public_html/', '' )
    else:
    	page = 'index.html'
    Yes indeed if something wrong is given as htmlpage then variable page default to index.html.

    I still dotn see the interacton though.
    What is now proved was once only imagined!
  18. #10
  19. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    So, any suggestions-assumptions?
    What is now proved was once only imagined!
  20. #11
  21. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Well, I suppose I didn't explicitly say "Please post the entire contents of the metrites.py script" so only posting a few lines does satisfy the requirements. Too bad I didn't spell it out, huh?

    From the top:

    1. You have /home/dauwin/public_html/.htaccess which says that requests for any existing file go to the metrites.py script.
    2. Given what little you've shown of that script I can only deduce that it does not support showing anything under /home/dauwin and will default to showing /home/nikos/public_html/index.html when all else fails.
    3. You still haven't told me whether mod_userdir is enabled. I'm going to keep assuming it is unless you say otherwise.
    4. mod_userdir will automatically map the /~dauwin URL, which would otherwise result in a 404 (probably), to the /home/dauwin/(public_html|www) folder.

    Thus,
    5. /~dauwin will map to /home/dauwin/www which automatically loads /home/dauwin/www/index.html which exists and will thus go through the metrites.py script which will completely ignore that filename and show /home/nikos/public_html/index.html instead.

    [edit] Ah yes, I need to spell things out don't I? Your options are
    a) Stop the process at step 1 by not using the .htaccess. This is probably your best bet because it doesn't seem like you need the "templating" stuff
    b) Stop the process at step 2 by making the script support /home/dauwin files
    Steps 3 and 4 are required because you need /~dauwin to work so you can't do anything there.
    Last edited by requinix; June 10th, 2013 at 03:12 PM.
  22. #12
  23. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    yes at some points ihad /home/nikos isntead of /home/dauwin

    i need index.html to be sent as template to metrites.py because metrites.py keeps track of counetrs of every htm lpgae requested.

    Weird i ahve made many changes 5 hours now but i notice that the problem is thet when i


    http://superhost.gr/~dauwin/

    the error shows:

    [Tue Jun 11 15:09:51 2013] [error] [client 79.103.41.173] File "/home/nikos/public_html/cgi-bin/metrites.py", line 222, in <module>
    [Tue Jun 11 15:09:51 2013] [error] [client 79.103.41.173] with open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:


    why on earth does it try to open from the peth

    '/home/nikos/public_html/'

    instead of the path

    '/home/dauwin/public_html/'

    i just dont understan dhow it gets associated like that.
    Last edited by Nik; June 11th, 2013 at 07:12 AM.
    What is now proved was once only imagined!
  24. #13
  25. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13

    Question


    Code:
    file = form.getvalue('file')
    page = form.getvalue('page')
    
    if not page and os.path.exists( file ):
    	# it is an html template
    	page = file.replace( '/home/dauwin/public_html/', '' )
    elif page or form.getvalue('show'):
    	# it is a python script
    	page = page
    else:
    	#when everything else fails default
    	page = page
    
    ....
    ....
    
    	if page.endswith('.html'):
    		with open( '/home/dauwin/public_html/' + page, encoding='utf-8' ) as f:
    			htmlpage = f.read()
    		htmlpage = htmlpage % (quote, music)
    		template = htmlpage + counter
    	elif page.endswith('.py'):
    		pypage = subprocess.check_output( '/home/dauwin/public_html/cgi-bin/' + page )
    		pypage = pypage.decode('utf-8').replace( 'Content-type: text/html; charset=utf-8', '' )
    		template = pypage + counter
    
    	print( template )
    Everything as you see point to 'dauwin' username, yet the error still says:

    Code:
    [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 219, in <module>, referer: http://superhost.gr/
    [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]     with open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:, referer: http://superhost.gr/
    [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173] FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd \\u03c5\\u03c0\\u03ac\\u03c1\\u03c7\\u03b5\\u03b9 \\u03c4\\u03ad\\u03c4\\u03bf\\u03b9\\u03bf \\u03b1\\u03c1\\u03c7\\u03b5\\u03af\\u03bf \\u03ae \\u03ba\\u03b1\\u03c4\\u03ac\\u03bb\\u03bf\\u03b3\\u03bf\\u03c2: '/home/nikos/public_html//home/dauwin/public_html/index.html', referer: http://superhost.gr/
    Why is pointing to /home/nikos isntead of /home/dauwin ?

    this is what a smash my head to the wall to understand.
    What is now proved was once only imagined!
  26. #14
  27. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    please suggest something.....
    What is now proved was once only imagined!
  28. #15
  29. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13

    Question


    > ======================
    > RewriteEngine On
    > RewriteCond %{REQUEST_FILENAME} -f
    > RewriteRule ^/?(.+\.html)
    > /cgi-bin/metrites.py?file=%{__REQUEST_FILENAME} [L,PT,QSA]
    > ======================
    >
    >
    Code:
    >     file = form.getvalue('file')
    >     page = form.getvalue('page')
    > 
    >     if not page and os.path.exists( file ):
    >              # it is an html template
    >              page = file.replace( '/home/dauwin/public_html/', '' )
    >     elif page or form.getvalue('show'):
    >              # it is a python script
    >              page = page..replace(
    >     '/home/dauwin/public_html/cgi-__bin/', '' )
    >     else:
    >              #when everything else fails fallback
    >              page = "index.html"
    > 
    >     ....
    >     ....
    > 
    >              if page.endswith('.html'):
    >                      with open( '/home/dauwin/public_html/' + page,
    >     encoding='utf-8' ) as f:
    >                              htmlpage = f.read()
    >                      htmlpage = htmlpage % (quote, music)
    >                      template = htmlpage + counter
    >              elif page.endswith('.py'):
    >                      pypage = subprocess.check_output(
    >     '/home/dauwin/public_html/cgi-__bin/' + page )
    >                      pypage = pypage.decode('utf-8').__replace(
    >     'Content-type: text/html; charset=utf-8', '' )
    >                      template = pypage + counter
    > 
    >              print( template )
    >
    >
    > Everything as you see point to 'dauwin' username, yet the error
    > still says:
    >
    >
    Code:
    >     [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]   File
    >     "/home/nikos/public_html/cgi-__bin/metrites.py", line 219, in
    >     <module>, referer: http://superhost.gr/
    >     [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]     with
    >     open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:,
    >     referer: http://superhost.gr/
    >     [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173]
    >     FileNotFoundError: [Errno 2] \\u0394\\u03b5\\u03bd
    >     \\u03c5\\u03c0\\u03ac\\u03c1\\__u03c7\\u03b5\\u03b9
    >     \\u03c4\\u03ad\\u03c4\\u03bf\\__u03b9\\u03bf
    >     \\u03b1\\u03c1\\u03c7\\u03b5\\__u03af\\u03bf \\u03ae
    >     \\u03ba\\u03b1\\u03c4\\u03ac\\__u03bb\\u03bf\\u03b3\\u03bf\\__u03c2:
    >     '/home/nikos/public_html//__home/dauwin/public_html/index.__html',
    >     referer: http://superhost.gr/
    >
    >
    >
    > Notice that you have the file path you want concatenated to your
    > /home/nikos/... stuff in the line above. Look in your code to find out
    > why. Fix that. Lather, rinse, repeat

    In my source code as seen above i mention nowhere for '/home/nikos/' but instead for '/home/dauwin/'

    That error message makes me come to conclusion that metrites.py script is running from user's nikos' cgi-bin:

    /home/nikos/public_html/cgi-bin/metrites.py

    instead of:

    /home/dauwin/public_html/cgi-bin/metrites.py

    I wonder why.
    I mean iam sayign it clearly

    with open( '/home/dauwin/public_html/' + page,

    and the error says:

    [Tue Jun 11 21:59:31 2013] [error] [client 79.103.41.173] with
    > open( '/home/nikos/public_html/' + page, encoding='utf-8' ) as f:,
    > referer: http://superhost.gr/

    What happens when i give http://superhost.gr/~dauwin

    Why home/nikos/public_html/cgi-bin/metrites.py seems to be the scritp that always run?

    That should have run when i browser: 'http://superhost.gr' and not when i browse 'http://superhost.gr/~dauwin'

    Please help. A client wanst to utilize my metrites.py script because he lieks the way that has a seperate counter for each html page and the way the log is presented in an html table like form.
    Of course i will give it it to him for free.
    What is now proved was once only imagined!
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo