How can .htaccess be utilized to manage URL redirection in PHP?
To manage URL redirection in PHP using .htaccess, you can set up rules in the .htaccess file to redirect certain URLs to different pages on your website. This can be useful for creating clean and user-friendly URLs, redirecting old URLs to new ones, or implementing URL shortening.
```php
RewriteEngine On
RewriteRule ^old-url$ /new-url [L,R=301]
```
This code snippet will redirect any requests for "old-url" to "new-url" with a 301 (permanent) redirect status. Make sure to replace "old-url" and "new-url" with the actual URLs you want to redirect.
Keywords
Related Questions
- How can PHP developers ensure compatibility and consistency when working with EXIF data across different PHP versions?
- What steps can be taken to ensure the proper order and naming of fields in an INSERT query in PHP to avoid errors?
- What is the difference between validating POST and GET requests in PHP?