View Full Version : "imitation" folders in url
pghcollectibles
04-18-2008, 11:39 AM
whether you have links or forms sending variables to a page, the url will show: page/?variable=something&another=something_else etc...
ive looked at redirect and htaccess and neither seem to be the answer for my question (if its even possible) i will give an example of what i want to do:
<a href="<?php echo $folder1; ?>"><?php echo $folder1; ?></a>
<a href="<?php echo $folder2; ?>"><?php echo $folder2; ?></a>
<a href="<?php echo $folder3; ?>"><?php echo $folder3; ?></a>
<a href="<?php echo $folderetc; ?>"><?php echo $folderetc; ?></a>
i want the url to appear as if thats where you are (even though those folders will not exist) but you are actually going to:
page/folder/index.php?url=1
page/folder/index.php?url=2
page/folder/index.php?url=3
page/folder/index.php?url=etc
can this be done?
pghcollectibles
04-18-2008, 12:00 PM
i have found these for htaccess but i dont know what they actually mean. the first is for file the second is for directory
Options +FollowSymLinks
RewriteEngine on
RewriteRule http://www(.*)\.htm$ /folder/index.php?url=$1
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/$ /folder/index.php?$1=$2
i wouldnt know where to put them as i would like folder1, folder2 etc. to not have to exist.
some kind of super form-php-htaccess code
studio
05-22-2008, 08:54 AM
If I am understanding you correctly, Apache's mod_rewrite is just what you're looking for. Your second post is an example of this.
The basic concept is this: if you have a long and complicated URL with a bunch of GET variables, you can tell Apache to map some other, simple URL to the exact same page. Apache uses regular expressions to do this.
Example:
RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)$ /$1.php?var1=$2&var2=$3&var3=$4
This Rewrite will "redirect" a URL request such as
www.host.com/script/var1/var2/var3
to
www.host.com/script.php?var1=var1&var2=var2&var3=var3
The user will still see www.host.com/script/var1/var2/var3 in their address-bar.
To make this work, simply put your rewrite rule (and perhaps the RewriteEngine On) directive in your .htaccess file (located in /home/username/public_html/.htaccess)There are some good tutorials out there, one I've found useful is at http://www.sitepoint.com/article/guide-url-rewriting .
pghcollectibles
05-30-2008, 03:20 PM
ive read that article and ive downloaded a cheat sheet from another site which looks useful. i will be learning more on this very soon, but...
i was wondering if you can rewrite to another url completely. i want to make a couple rules so i can type for example:
http://www.mysite.com/google and the page shown will really be http://www.google.com
then i can make a different page that will have links to:
/google
/mail
/accounts
/etc
instead of using my bookmarks, and my url address box will always have mysite/whatever_im_working_on
could someone post the code just for the basic function im describing with the google redirect as an example
pghcollectibles
05-31-2008, 09:35 AM
as a test i put this into the .htaccess:
RewriteEngine on
RewriteRule ^(.*)$ http://www.google.com/ [L]
it redirects but i thought htaccess can be used to mask the url address bar i must have missed that part and i hate to reread all those pages again if you are using htaccess for search friendly urls then i would think it would have to mask or the user would hit bookmark and it would be the long url still.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.