What role does the .htaccess file play in redirecting URLs in PHP websites?
The .htaccess file is used to configure how a web server handles requests. In the context of redirecting URLs in PHP websites, the .htaccess file can be used to set up URL redirects, rewrite URLs, and handle routing. This is commonly done to create clean URLs, redirect old URLs to new ones, or handle custom routing logic.
RewriteEngine On
RewriteRule ^old-url$ /new-url [R=301,L]
Related Questions
- What are the drawbacks of using whitelists to filter out certain characters in user input, and what alternative approaches can be considered?
- What are the potential challenges of splitting date ranges in PHP, especially when dealing with nested slots within a base range?
- What are the potential pitfalls of storing all 1326 possible solutions in a MySQL table for a poker calculator in PHP?