Habble
Oct 26 2007, 04:33 AM
| | Hi Is it possible to set up a script somehow, where you go to www.domain.com/directory/directory1, 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 www.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? |
Comment/Reply (w/o sign-up)
turbopowerdmaxsteel
Oct 26 2007, 06:49 AM
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 www.domain.com/directory/?directory=directory1 I am not much aware of Linux and the htaccess magic, but I do believe this could be done.
Comment/Reply (w/o sign-up)
Sten
Oct 26 2007, 06:54 AM
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
Comment/Reply (w/o sign-up)
pyost
Oct 26 2007, 08:50 AM
Just as turbopowerdmaxsteel said, .htaccess is all you need  CODE RewriteEngine on
RewriteRule ^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 www.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.
Comment/Reply (w/o sign-up)
Habble
Oct 27 2007, 03:33 AM
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: CODE # -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 habble-aus.com AuthUserFile /home/habbleau/public_html/_vti_pvt/service.pwd AuthGroupFile /home/habbleau/public_html/_vti_pvt/service.grp
RewriteEngine on
RewriteRule ^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.php Um, Can anyone help this time?
Comment/Reply (w/o sign-up)
pyost
Oct 27 2007, 08:27 AM
Try this instead CODE 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=...
Comment/Reply (w/o sign-up)
turbopowerdmaxsteel
Oct 27 2007, 08:37 AM
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. CODE RewriteRule ^profiles/([a-z,A-Z,0-9]+)$ profiles/index.php?name=$1
Comment/Reply (w/o sign-up)
Habble
Oct 28 2007, 02:27 AM
Thanks! I've got it working using pyost's script. The finished thing now looks like this: RewriteEngine on RewriteCond %{REQUEST_URI} !/profiles/index.php RewriteRule ^profiles/(.*) profiles/index.php?name=$1
Comment/Reply (w/o sign-up)
Sten
Oct 28 2007, 03:27 AM
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.
Comment/Reply (w/o sign-up)
Quatrux
Oct 28 2007, 05:56 AM
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.
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : Dynamic Directories
Looking for dynamic, directories
|
|
*SIMILAR VIDEOS*
Searching Video's for dynamic, directories
|
advertisement
|
|