Home  >  Q&A  >  body text

How to process a directory in the URL as a parameter

I'm sure I need to use some overridden conditionals to handle this, but I don't quite understand it yet.

Take a sample URL as an example:

https://example.com/guest-area/{TENANT-NAME}/login

Here, {TENANT-NAME} should be treated as a GET parameter by PHP, so actually the URL should be treated as:

https://example.com/guest-area/login/?tenant={TENANT-NAME}

However, it should appear in the address bar like the first example and be accessible to the user.

The value of

{TENANT_ID} will always come after /guest-area, so anything given between the next set of forward slashes should be treated as $_GET['tenant']Instead of a directory. Any directory after it (e.g. /login) is a "real" directory.

P粉154798196P粉154798196306 days ago407

reply all(1)I'll reply

  • P粉060112396

    P粉0601123962024-01-11 15:28:03

    Put this content into your .htaccess file

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^guest-area/(.*)/login /guest-area/login/?tenant=
    RewriteRule ^guest-area/(.*)/login/ /guest-area/login/?tenant=

    reply
    0
  • Cancelreply