Page 1 of 1
Setup like php.net/this?
Posted: Tue Dec 12, 2006 12:16 am
by FuzzyLogik
I would like to set up my page to be able to be used like this:
http://www.mysite.com/this
or
http://www.mysite.com/that
(without creating separate folders for each and making an index file )
I am using apache, so if I have to use .htaccess, I can.
Posted: Tue Dec 12, 2006 12:36 am
by dibyendrah
Yes, you can do that with .htaccess file.
Posted: Tue Dec 12, 2006 12:45 am
by FuzzyLogik
dibyendrah wrote:Yes, you can do that with .htaccess file.
Can I get a bit of an explanation?
I was going to use:
Code: Select all
RewriteRule ^([A-Za-z]+)$ page.php?page=$1
Posted: Tue Dec 12, 2006 1:11 am
by dibyendrah
FuzzyLogik wrote:dibyendrah wrote:Yes, you can do that with .htaccess file.
Can I get a bit of an explanation?
I was going to use:
Code: Select all
RewriteRule ^([A-Za-z]+)$ page.php?page=$1
This change the default directory page into the given default page.
If you want to open mydefaultpage.php when you visit some url suppose :
http://xyz.com/pub/
and you want mydefaultpage.php to be opened rather than index.php. use
And in your case,
Code: Select all
RewriteRule ^([A-Za-z]+)$ page.php?page=$1
RewriteRule is not needed for your current need. They are basically used for security reasons. It might be preventing from hotlinking etc...
Posted: Tue Dec 12, 2006 1:43 am
by FuzzyLogik
I don't think you understand what I am trying to do
If you go to php.net/mail it goes to a different place than php.net/include
I want to do that with my site...
I figured it out, sorta:
RewriteRule ^([A-Za-z]+)/{[0-9+])$ index.php?word=$1
This works perfectly.
I say mysite.com/word and it goes to mysite.com/index.php?word=word
The problem is, I need multiple selectors for my static links (home/about/contact, etc)
so I tried:
RewriteRule ^home$ index.php?page=home
But the two of them don't play nice together.. the one on top trumps the one on bottom.
Anyone know how to fix this?
Thanks.
Posted: Tue Dec 12, 2006 1:46 am
by volka
Posted: Tue Dec 12, 2006 3:01 am
by dibyendrah
FuzzyLogik wrote:I don't think you understand what I am trying to do
If you go to php.net/mail it goes to a different place than php.net/include
I want to do that with my site...
I figured it out, sorta:
RewriteRule ^([A-Za-z]+)/{[0-9+])$ index.php?word=$1
This works perfectly.
I say mysite.com/word and it goes to mysite.com/index.php?word=word
The problem is, I need multiple selectors for my static links (home/about/contact, etc)
so I tried:
RewriteRule ^home$ index.php?page=home
But the two of them don't play nice together.. the one on top trumps the one on bottom.
Anyone know how to fix this?
Thanks.
Okay. I thought you are trying to load different default pages for folders.
In your URL
http://www.mysite.com/this
I thought "this" was folder rather than file. Sorry for misunderstanding.
So, are you trying to achive somehing like
http://www.php.net/urlhowto.php ?