如何在共享主机中创建动态子域


How to make dynamic subdomain in shared hosting

我想在共享主机中创建动态子域,但我无法访问httpd.conf文件和任何服务器文件。我已经在我的面板中创建了一个通配符子域。

我只是想创建这个网址:www.example.com/books.php?tag=爱的书&current_page=2(在.htaccess操作后,url为www.example.com/Love-books/2),以便像http://www.Love-books.example.com这样的子域和所有其他url一样正常工作。我的.htaccess文件上有以下代码:

RewriteEngine On
RewriteRule '.(css|jpe?g|gif|png|js)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^authors/([^/]*)$ authors.php?current_page=$1 [NC,L]
RewriteRule ^([^/]*)/([^/]*)$ books.php?tag=$1&current_page=$2 [NC,L]
RewriteRule ^Books-single/([^/]*)/([^/]*)$ book-single.php?tag=$1&id=$2 [NC,L]
RewriteRule ^Books-by/([^/]*)/([^/]*)$ book-by.php?auth=$1&current_page=$2 [NC,L]
RewriteRule ^authors-by/([^/]*)/([^/]*)$ authors-by.php?author-by=$1&current_page=$2 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}'.php -f 
RewriteRule ^(.*)$ $1.php

本指南可以帮助您理解以下过程:使用.htaccess文件和PHP动态创建子域。