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
- How can using the $_POST superglobal in PHP help prevent issues related to register_globals and improve the security and reliability of scripts that handle user input?
- How does the choice of database and charset affect the handling of special characters in PHP?
- What are the common pitfalls to avoid when using PHP for form submissions?