How can we append an extra 'path' after base domain in nginx rewrite such as: http://www.thissite.com to http://www.thissite.com/main (so does http://www.thissite.com/hallo to http://www.thissite.com/main/hallo and so on)?
-
-
Answer:
I am not exactly sure what you are trying to accomplish, however if all you want to do is append a url such as http://www.this-domain.comm[/code] in such a way that it is becomes www.this-domain.com/ You could do this with the following php snippet: <?php $dnm1="www.this-domain.com"; if (preg_match('/\b([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b/i', $dnm1)) { # Successful match $dnm=$dnm1."/"; echo $dnm; } else { # Match attempt failed end; } ?> The above regex is explained: Assert position at a word boundary (position preceded or followedâbut not bothâby a Unicode letter, digit, or underscore) «\b» Match the regex below and capture its match into backreference number 1 «([a-z0-9]+(-[a-z0-9]+)*\.)+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match a single character present in the list below «[a-z0-9]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» A character in the range between âaâ and âzâ (case insensitive) «a-z» A character in the range between â0â and â9â «0-9» Match the regex below and capture its match into backreference number 2 «(-[a-z0-9]+)*» Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» Match the character â-â literally «-» Match a single character present in the list below «[a-z0-9]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» A character in the range between âaâ and âzâ (case insensitive) «a-z» A character in the range between â0â and â9â «0-9» Match the character â.â literally «\.» Match a single character in the range between âaâ and âzâ (case insensitive) «[a-z]{2,}» Between 2 and unlimited times, as many times as possible, giving back as needed (greedy) «{2,}» Assert position at a word boundary (position preceded or followedâbut not bothâby a Unicode letter, digit, or underscore) «\b»
Steve Kinzey at Quora Visit the source
Other answers
location / { rewrite ^ http://http://www.thissite.com//main permanent; } location /hallo { rewrite ^ http://http://www.thissite.com//main/hallo permanent; }
Rick WR
Related Q & A:
- How can I redirect www to non www site?Best solution by Server Fault
- How can I stop eating extra foods?Best solution by prevention.com
- How do I change the alias on my Yahoo! domain name to web.me.com?Best solution by Yahoo! Answers
- How can I find my career path?Best solution by eHow old
- Can you trust www.branddream.com?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.