Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - rewrite url with dynamic host name

I need to rewrite url with rule like below

RewriteRule ^files/([a-z0-9-\.]+)$ files/domain.com/$1

domain.com is current host name. It is dynamic (don't ask why plz). So I can not do like this. Anyway, how I can get current host name and put it like this:

RewriteRule ^files/([a-z0-9-\.]+)$ files/{{ current host name with out www. }}/$1
like image 731
complez Avatar asked Jul 16 '26 00:07

complez


1 Answers

%{HTTP_HOST} will give you the requested host name.

I can't test right now whether it can be used in a RewriteRule, but I think it can.

like image 50
Pekka Avatar answered Jul 17 '26 13:07

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!