Not sure if this is possible, but what I'm looking to do is have users directed to the exact same directory and file regardless of what particular URL path they come from.
For example, I would like test.mysite.com/person1
and test.mysite.com/person2
to come to the same index page.
Some pseudo-code for my .conf (nginx):
server {
listen 80;
server_name test.mysite.com/person1;
location / {
root /home/testing/public_html;
index index.html;
try_files $uri $uri/ /index.php?$args;
port_in_redirect off;
}
Can I do something like:
server {
listen 80;
server_name test.mysite.com/*; //Something here that indicates wildcard
location / {
root /home/testing/public_html;
index index.html;
try_files $uri $uri/ /index.php?$args;
port_in_redirect off;
}
The entire point of this is that I'm going to supply "personal" URLs to people that include their name like so: test.mysite.com/person1
. I'll use javascript to get the unique part of the URL ("person1") and use that to serve custom content via PHP, etc.
Essentially, I don't want the last part of the URL to change the directory that I serve the index file from.
Thanks.
The trick here was changing server_name
and not location
server {
listen 80;
server_name ~^(test).*\.mysite\.com$;
location / {
root /home/testing/public_html;
index index.html;
try_files $uri $uri/ /index.php?$args;
port_in_redirect off;
}