Jump to content

PHP read url in folder form instead of querystring


mosidiot

Recommended Posts

Hi,

 

how to let php read the url in folder form instead of querystring?

 

e.g.

 

www.example.com/index.php?post=123

www.example.com/post/123/

 

both is actually directed to the same page - index.php, but how to make it read like a folder when the physical path doesn't really exist?

Link to comment
Share on other sites

Yeah I figured he wanted apache's mod_rewrite, but how does one get access to the index.php of

 

www.example.com/post/123/

 

if the physical path doesn't exist, and no rewrite rules are in use.

 

The idea of a mod_rewrite is so when a user types in the address http://www.example.com/post/123/ it will be "re-written" to be whatever the mod_rewrite rule tells it.

Link to comment
Share on other sites

Thanks guys!

 

objNoob,

Thanks, thanks a good solution, I see websites or CMS software did something like that without htaccess rewriterule

 

I realized using htaccess utilized less resources and faster. Thanks a lot for your solution anyway! I will use it when I need to bypass apache mod or probably in IIS host.

 

Buddski

Yup, thanks.. Google indeed helps! I wasn't sure what kind of term it used for this kind of redirection.

 

Example is as follows:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^products/([^/]+)$ index.php?prodID=$1

 

 

Thanks guys for the kind help! Really appreciated that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.