How can mod_rewrite be used to modify URLs in PHP applications?
Mod_rewrite can be used in PHP applications to modify URLs by rewriting them to a different format. This can be useful for creating user-friendly URLs, redirecting old URLs to new ones, or implementing URL routing in MVC frameworks. By using mod_rewrite in conjunction with an .htaccess file, developers can easily manipulate URLs without changing the underlying PHP code.
RewriteEngine On
RewriteRule ^old-url$ new-url [L,R=301]
Keywords
Related Questions
- What are common debugging techniques for PHP applications, especially when encountering issues like "Object not found" after a login attempt?
- What are the potential pitfalls of using pixel counting for alignment in PHP?
- In PHP, what are the best practices for handling form submissions and accessing form data?