iGuest 3 Report post Posted October 26, 2007 HiIs it possible to set up a script somehow, where you go to http://forums.xisto.com/no_longer_exists/, ecxept you can relace directory1 with anything, and it will run the same script, whether a directory called directory1 exists in the folder directory or not?Say, for example, you go to http://www1.domain.com/directory/ Hello and a page comes up that says "Your text: Hello", even though a "Hello" directory doesn't exist? I can think of no way of doing this with PHP, and the only way I can think of being able to do it is with serverside scripting that you obvioulsy wouldn't be able to do with a hosting account.The other way of doing something like this, which I think you might be able to set up via cPanel (Although I don't know how), is set up a script so that whenever someone tries to access the directory "directory", it checks to see if they're tring to access another directory inside that, and if they are, create that directory, so they can access it, and then destroy it later.Can anyone help? Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted October 26, 2007 PHP is a server side scripting language. I suppose you can use mod rewrite in .htaccess file to redirect any such path to a PHP file, with the directory name as the input, say http://www1.domain.com/directory/ I am not much aware of Linux and the htaccess magic, but I do believe this could be done. Share this post Link to post Share on other sites
Sten 0 Report post Posted October 26, 2007 well jay u no that it can be done cos other fansites do it.and it works for everyone u type in not just members.you could ask other fansites about what they did about it or ask on habbos.net Share this post Link to post Share on other sites
pyost 0 Report post Posted October 26, 2007 Just as turbopowerdmaxsteel said, .htaccess is all you need RewriteEngine onRewriteRule ^directory/(.+)$ /directory/script.php?directory=$1 Regular expression, which are used in .htaccess files, might be confusing in the beginning, but they are an extremely powerful tool. ^directory/(.*)$ will match all the URLs which start with http://www1.domain.com/directory/ and end with any text, which we capture with the use of paranthesis - the dot signifies any character, and the plus sign means "one or more of the previous" (which is in our case any character). After that, we just use $1 as a reference to the first thing we captured, or in other words the .+ part. After that, it's all PHP. Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 27, 2007 (edited) Thanks. I'd never taken much notice of the .htaccess files, I never realised they did anything, lol.Perhaps I should have a look at what other things .htaccess can do.Edit:Ok, my .htaccess file looks like this: # -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName habble-aus.comAuthUserFile /home/habbleau/public_html/_vti_pvt/service.pwdAuthGroupFile /home/habbleau/public_html/_vti_pvt/service.grpRewriteEngine onRewriteRule ^profiles/(.*) profiles/index.php?name=$1 What this should do, is (say) if I go to profiles/abc, it should go to profiles/index.php?name=abc. But it isn't. It seems to be going to profiles/index.php?name=index.phpUm, Can anyone help this time? Edited October 27, 2007 by Habble (see edit history) Share this post Link to post Share on other sites
pyost 0 Report post Posted October 27, 2007 Try this instead RewriteCond %{REQUEST_URI} !^profiles/index.php [NC]RewriteRule ^profiles/(.*) profiles/index.php?name=$1 I'm not that good when it comes to .htaccess, but it seems to me that you must prevent redirection when (.*) is index.php?name=... Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted October 27, 2007 Suppose you go to the path profiles/abc, due to the RewriteRule, the internal URL would be profiles/index.php?name=abc. Again, this URL matches the condition you specified in the RewriteRule ^profiles/(.*). So, the new URL becomes profiles/index.php?name=index.php. Instead, use the following code. It redirects the URL only when the part after profiles/ contains a-z, A-Z and 0-9 characters. You can modify the code to include other characters like _ and - . Just don't allow the dot character in the username. RewriteRule ^profiles/([a-z,A-Z,0-9]+)$ profiles/index.php?name=$1 Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 28, 2007 Thanks! I've got it working using pyost's script. The finished thing now looks like this:RewriteEngine onRewriteCond %{REQUEST_URI} !/profiles/index.phpRewriteRule ^profiles/(.*) profiles/index.php?name=$1 Share this post Link to post Share on other sites
Sten 0 Report post Posted October 28, 2007 when i go to a profile that isnt a habble member, all i get is the users hotel is offline.i gather its not meant to work yet cos also the different countires and that. Share this post Link to post Share on other sites
Quatrux 4 Report post Posted October 28, 2007 Another way to do it is to use in php $_SERVER['PATH_INFO']; in that way you can get values from index.php/directory1/value2 or anything you like, moreover if you don't like seeing index.php in the url line, then you also can use .htaccess to make it look like /directory1/value2 and use the same PHP stuff, in this case, the mod rewrite will be much easier. Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 30, 2007 when i go to a profile that isnt a habble member, all i get is the users hotel is offline.i gather its not meant to work yet cos also the different countires and that. Well it's sort of hard to magically detect someones details when they're not a member. Share this post Link to post Share on other sites