How can mod_rewrite be used to redirect URLs in PHP?
Mod_rewrite can be used in PHP to redirect URLs by creating rewrite rules in the .htaccess file. These rules can be used to redirect incoming requests to a different URL based on certain conditions, such as matching a specific pattern or query string parameter. By using mod_rewrite, you can easily manage URL redirections without having to modify your PHP code.
RewriteEngine on
RewriteRule ^old-url$ /new-url [L,R=301]
Keywords
Related Questions
- What are the alternatives to the TEXT data type for storing large amounts of text in a MySQL database?
- What are some best practices for structuring and organizing PDO code in PHP applications?
- When creating a file based on user input from a form, what are the best practices to ensure that the file name contains only valid characters in PHP?