piyush23424 Posted August 17, 2010 Share Posted August 17, 2010 Hi.. Please tell me how to get the id from url if url is like this http://localhost/test.php/id/123 Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/210948-how-to-get-the-id-from-url/ Share on other sites More sharing options...
trq Posted August 17, 2010 Share Posted August 17, 2010 That url looks like it has been rewritten by mod_rewrite, do you have a .htaccess file? Quote Link to comment https://forums.phpfreaks.com/topic/210948-how-to-get-the-id-from-url/#findComment-1100257 Share on other sites More sharing options...
piyush23424 Posted August 17, 2010 Author Share Posted August 17, 2010 That url looks like it has been rewritten by mod_rewrite, do you have a .htaccess file? no, i haven't made any htaccess file because i need this thing only on one page and .htaccess file may disturb the other pages, so i am avoiding to use it. Please tell me if it is possible with php if it is not possible in php then pls explain how can i do this with .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/210948-how-to-get-the-id-from-url/#findComment-1100266 Share on other sites More sharing options...
trq Posted August 17, 2010 Share Posted August 17, 2010 The url needs to be rewritten otherwise your server will literally look for a file called 123 Quote Link to comment https://forums.phpfreaks.com/topic/210948-how-to-get-the-id-from-url/#findComment-1100269 Share on other sites More sharing options...
piyush23424 Posted August 17, 2010 Author Share Posted August 17, 2010 The url needs to be rewritten otherwise your server will literally look for a file called 123 hello, I have created a .htaccess file as you suggested that is working fine but now it is not linking the css and not even showing any images on the page. I think its because of change in the url here is the code for .htaccess file Options +FollowSymLinks RewriteEngine on RewriteRule buynote/id/(.*)/ buynote.php?id=$1 RewriteRule buynote/id/(.*) buynote.php?id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/210948-how-to-get-the-id-from-url/#findComment-1100290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.