I have a local website running on localhost. I have .htaccess file with the below code.This is for removing .php extension from the url. What should be added if I just want localhost or ip-address displayed in the url? Thanks
You’re NOT removing php from the URI with this code, you’re redirecting to the php script (if it exists).
You might benefit from reading the mod_rewrite tutorial (http://dk.co.nz/seo) as it contains explanations and sample code. It’s helped may members and should help you, too.
[rant #4]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an … wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/rant 4]
Hmmm, so much for that pet peeve of mine!
Localhost or IP Address? How are you accessing your php script on localhost? In other words, your link will only work if you’re using http://localhost/… (unless you’ve setup a virtual host but I doubt that the IP Address would work because you can have many virtual hosts at the one IP Address).
Actually, after adding the above mentioned .htaccess file, the website was still showing the .php extensions in the url so I had to remove the .php extension from redirection links i.e header(" location: login.php") was changed to header("location: login"). Also from JS codes, window.open("test","_self"); .
To REMOVE the file extension and still serve the PHP file, you’ll need a trick or two. That is well documented in my tutorial …
You might benefit from reading my mod_rewrite tutorial at http://dk.co.nz/seo as it contains explanations and sample code. It’s helped many SitePoint members over the years and should help you, too.
It’s in the example code (and discussion) for “Loopy Code”. PM or e-mail me directly if you have specific questions.