PHP url querystring question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eektech909
Forum Commoner
Posts: 34
Joined: Fri Jun 09, 2006 3:59 pm

PHP url querystring question

Post by eektech909 »

My boss doesn't like seeing the question mark in the url.

I explained how a querystring works but he's set in his ways.

I'd rather not create a bunch of folders with index files in each.

He doesn't want
http://www.example.com/?cat=one
http://www.example.com/?cat=two

Instead, he wants
http://www.example.com/one/
http://www.example.com/two/

Any way to do this?
User avatar
Peter Anselmo
Forum Commoner
Posts: 58
Joined: Wed Feb 27, 2008 7:22 pm

Re: PHP url querystring question

Post by Peter Anselmo »

You can do it with Apache's mod_rewrite module. I'd suggest Googling it to get the whole rundown.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Re: PHP url querystring question

Post by PrObLeM »

You can also do it in the .htaccess file

I'm pretty sure this will work

Code: Select all

 
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/(.+) /?cat=$1
 
eektech909
Forum Commoner
Posts: 34
Joined: Fri Jun 09, 2006 3:59 pm

Re: PHP url querystring question

Post by eektech909 »

I did some research and this is exactly what I am looking for. I contacted our hosting company about the .htaccess files.
I'm not very familiar with this.

Can I create an .htaccess file with this in it via text edit and drop it in the folder of the index.php?
User avatar
hawkenterprises
Forum Commoner
Posts: 54
Joined: Thu Feb 28, 2008 9:56 pm
Location: gresham,oregon
Contact:

Re: PHP url querystring question

Post by hawkenterprises »

Believe it or not there is an entire website and community devoted to this question

http://www.modrewrite.com/

I will say this though, if you are going to be doing 100k+ rewrites apache mod all though fast will take it's toll in performance, I would recommend a file based or combination solution to reach alot of pages/traffic.
eektech909
Forum Commoner
Posts: 34
Joined: Fri Jun 09, 2006 3:59 pm

Re: PHP url querystring question

Post by eektech909 »

Alright...

We don't personally host the site, but I guess we're running an IIS server.
We had ISAPI_Rewrite 3 Installed
Here's what i'm trying to convert

http://www.exampled.com/download/?cat=one
I made a txt file with the above code and renamed it to .htaccess and uploaded it to the directory but its not working

???
Post Reply