How can mod_rewrite be utilized to create "fictive" subdomains in PHP?
To create "fictive" subdomains in PHP using mod_rewrite, you can rewrite the URL to pass the subdomain as a query parameter to your PHP script. This way, you can dynamically generate content based on the subdomain.
```php
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$
RewriteRule ^(.*)$ index.php?subdomain=%1 [L,QSA]
```
In your PHP script (index.php), you can access the subdomain value using `$_GET['subdomain']` and use it to determine the content to display.
Keywords
Related Questions
- What are some best practices for handling data exchange between PHP and online shop systems to avoid compatibility issues?
- How can the use of GROUP_CONCAT in SQL queries improve the generation of invoices in PHP?
- What are the potential issues with generating multiple forms in PHP with the same ID for input elements?