Thinkphp URL path

Source: Internet
Author: User
Assume that the home page URL of your project is: Homepage...

Assume that the Homepage URL of your project is www.test.com/other/Form.

If the current module is: Index

If the current operation is: index

Then the home page complete URL: http://www.test.com/other/Form/index.php/Index/index

_ ROOT __:/other/thinkphp/mydemo

_ SELF __:/other/thinkphp/mydemo/Form/index. php

_ ACTION __:/other/thinkphp/mydemo/Form/index. php/Index/index

_ URL __:/other/thinkphp/mydemo/Form/index. php/Index

_ APP __:/other/thinkphp/mydemo/Form/index. php

_ PUBLIC __:/other/thinkphp/mydemo/Public

../Public (case insensitive):/other/thinkphp/mydemo/Form/Tpl/default/Public

APP_PUBLIC_URL:/other/thinkphp/mydemo/Form/Tpl/default/Public

WEB_PUBLIC_URL:/other/thinkphp/mydemo/Public

The path operation in the template is like this. PHP code:

  1. // Project Public Directory
  2. $ TmplContent = str_ireplace ('../public', APP_PUBLIC_URL, $ tmplContent );
  3. // Public website directory
  4. $ TmplContent = str_replace ('_ PUBLIC _', WEB_PUBLIC_URL, $ tmplContent );
  5. // Website root directory
  6. $ TmplContent = str_replace ('_ ROOT _' ,__ ROOT __, $ tmplContent );
  7. // Current project address
  8. $ TmplContent = str_replace ('_ APP _' ,__ APP __, $ tmplContent );
  9. // Address of the current module
  10. $ TmplContent = str_replace ('_ URL _' ,__ URL __, $ tmplContent );
  11. // Operation address of the current project
  12. $ TmplContent = str_replace ('_ ACTION _' ,__ ACTION __, $ tmplContent );
  13. // Operation address on the current page
  14. $ TmplContent = str_replace ('_ SELF _' ,__ SELF __, $ tmplContent );

Test URL: http: // localhost/blog/testurl. php? Id = 5

  1. // Obtain the domain name or host address
  2. Echo $ _ SERVER ['http _ host']."
  3. "; # Localhost
  4.  
  5. // Obtain the webpage address
  6. Echo $ _ SERVER ['php _ SELF ']."
  7. "; #/Blog/testurl. php
  8.  
  9. // Obtain URL parameters
  10. Echo $ _ SERVER ["QUERY_STRING"]."
  11. "; # Id = 5
  12.  
  13. // Obtain the user proxy
  14. Echo $ _ SERVER ['http _ referer']."
  15. ";
  16.  
  17. // Obtain the complete url
  18. Echo 'http: // '. $ _ SERVER ['http _ host']. $ _ SERVER ['request _ url'];
  19. Echo 'http: // '. $ _ SERVER ['http _ host']. $ _ SERVER ['php _ SELF']. '? '. $ _ SERVER ['query _ string'];
  20. # Http: // localhost/blog/testurl. php? Id = 5
  21.  
  22. // Complete url containing the port number
  23. Echo 'http ://'. $ _ SERVER ['server _ name']. ':'. $ _ SERVER ["SERVER_PORT"]. $ _ SERVER ["REQUEST_URI"];
  24. # Http: // localhost: 80/blog/testurl. php? Id = 5
  25.  
  26. // Only take the path
  27. $ Url = 'http: // '. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"];
  28. Echo dirname ($ url );
  29. # Http: // localhost/blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.