0

So currently all users profile page are loaded on path https://example.com/username. i want to change that and load user profile page on https://username.example.com.

i am using nginx as web server,below is the server block i have tried

server { listen 80; server_name *.example.com; if ($host ~ "^(.*)\.example\.com$") { set $subdomain $1;} rewrite ^ $scheme://example.com/$subdomain$request_uri permanent; } 

this redirects anyone who visit *.example.com to https://example.com/username which is my controller in CodeIgniter. is there a way to keep the url as username.example.com and load serve the content from https://example.com/username

3
  • Don't attempt to do rewrites in nginx. You need to handle this in your PHP code. Commented Aug 13, 2021 at 17:46
  • @MichaelHamptop i have no idea how to do that can you share with me an example ? Commented Aug 14, 2021 at 3:20
  • We don't do programming questions here. You can ask programming questions on Stack Overflow. Commented Aug 14, 2021 at 3:27

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.