Let's say I have a web server (nginx) server.com
where I have only one php file index.php
(there is no directory structure). I want to be able to access anything after server.com. It will be an url structure. For example server.com/google.com, server.com/yahoo.com.au etc...
An example would be http://whois.domaintools.com/google.com
(They don't have a directory that's called /google.com, right?)
Q1: How can I access whatever is after 'server.com' from index.php
Q2: Can I get the protocol from such URL? For example server.com/http://www.google.com
or server.com/https://www.google.com
PS I'm not certain if the term virtual directory is used here correctly. I just want to do what I saw somewhere else.
location / {
rewrite ^/(.*)$ /index.php?q=$1
}
location = /index.php {
#Do your normal php passing stuff here now
}
Is that what you were looking for?
As an answer to your second question, you can parse the protocol in php. Nginx doesn't need to do that. To parse the url, you can use the parse_url
function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With