我想用以下的通配符重写url:
致:
'any'是任何字符串,'fixed'是固定字符串。
感谢。
答案 0 :(得分:0)
尝试在.htaccess
文件中添加一些这样的重写规则:
RewriteEngine on
RewriteBase /
# Make sure it's not an actual file or
# directory, being accessed. If you wish.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
# Match the subdomain
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$
# Rewrite the request to the main domain:
# %1: The subdomain matched against HTTP_HOST in the previous RewriteCond.
# $1: The request URI.
RewriteRule ^(.*)$ https://example.com/fixed/%1/$1 [L,R,QSA]
如果它不是最后一次重写规则,请随意删除L
标志。有关详细信息,请参阅RewriteRule Flags。
你可以test it online。