API-How to implement PHP files without suffix access

Source: Internet
Author: User
Tags php framework
If the problem is very easy please forgive me, I use PHP not a few days now learn to use
I used the PHP framework of oauth2.0.
http://localhost/api/token.php address like this.
How to implement access with Http://localhost/api/token

I searched, but it may seem that my posture is not right (the keyword is wrong), Google can not search

Reply content:

If the problem is very easy please forgive me, I use PHP not a few days now learn to use
I used the PHP framework of oauth2.0.
http://localhost/api/token.php address like this.
How to implement access with Http://localhost/api/token

I searched, but it may seem that my posture is not right (the keyword is wrong), Google can not search

Upstairs said all right, but may landlord need a concise answer ...

Placed in the token directory index.php , you can use the http://localhost/api/token accesshttp://localhost/api/token/index.php

Cut
Oh Sorry ...

That's a little bit more complicated.

Add two words at the end of the .htaccess document

Rewriteengine on
Rewriterule ^ (api/token) token.php [L]

You'll be able to accept it through the root directory. token.php api/token

The first sentence is probably not, because there .htaccess may have been this sentence before.

Of course you may not have .htaccess a file at the moment, so you can create one yourself.

You may also find that .htaccess there is no effect, it is necessary to configure httpd.conf the ...

This issue is within the jurisdiction of the HTTP server, regardless of the PHP framework.

Some of the ways to consider this are:

    • HTTP rewrite technology to allow URLs that conform to specific regular expressions to be processed by a particular script (WordPress, for many programs, recommended)
    • HTTP redirection, and rewrite almost
    • Directly provide the token file soft connect to token.php , and then configure the HTTP server to make the token file even if no extension is also handled by the PHP interpreter (not recommended)
    • Even make a token/ directory, with the help of home page file is also a way

Specifically, you need to follow what your HTTP Server software is and then specifically query.

can be pseudo-static implementation

Just use pseudo-static on the line, the. PHP ignored

Many PHP frameworks support this, which is called URL routing

You can also rewrite all requests to a route, route assignment

  • 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.