FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


htaccess: virtual forwarding?





TomS
Hi at all.
Is it possible to make a .htaccess that does the following:
If a visitor enters "www.mysite.com/page1" the file "page1.php" will be loaded.
Or: If he enters this: "www.mysite.com/gallery/img123" the gallery.php will be openedn with "gallery.php?anyvar=img123"
???

Thanks in advance, TomS
mariohs
Yes, take a good read at the URLS! URLS! URLS! from the A List Apart site, and also in the How to Succeed With URLs article, which gives you some very nice tips about using mod_rewrite.

Take a look also at some examples using mod_rewrite.

The official documentation of mod_rewrite

Mastering regular expressions is also a good key to succeed with rewriting urls Very Happy
TomS
Thank you so much. Hope it will help me. Otherwise I'll come back... Wink
mariohs
TomS wrote:
Thank you so much. Hope it will help me. Otherwise I'll come back... Wink

No problem... Just glad to help.

If you manage to do it, come back and post here the results Very Happy
rohan2kool
[my question here too; don't wanna start a new thread]

if i'm not mistaken, for the RewriteCond (or something similar), Apache uses regular expressions. I had a cursory glance at some cheat sheet for mod_rewrite. Looked like regex's to me...
TomS
Hehe. Works now. After some tests...

http://pureattraction.frih.net/htaccess/ This should lead to index.htm

http://pureattraction.frih.net/htaccess/id2/ This should lead to index2.htm

Code:
RewriteEngine On
RewriteRule ^id2/ index2.htm
ErrorDocument 404 index.htm
ErrorDocument 500 index.htm


I just wonder why "http://pureattraction.frih.net/htaccess/index" also leads to index.htm. It should cause an 404 Error....
And if the suffix is anything other than id2/ I get an 500 Error, but not the index.htm is shown but the standard errormessage of apache.
Related topics
htaccess Password Protection
.htaccess tutorial
Url Forwarding
CANT UPLOAD .htaccess, .htpasswd, .header, .footer
[tutor] How to protect images without htaccess using PHP
.htaccess IP Blocking
Custom error pages using .htaccess
Port Forwarding
A Question For .htaccess
Frontpage Ext. Problems!!
.htaccess
EasyJet Virtual
How to "folder forward"?
Virtual Worlds built on OpenSimulator
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.