A
A
askogorev2014-09-05 11:40:23
PHP
askogorev, 2014-09-05 11:40:23

How to make Submit form (html) GET given htaccess location?

there is such a rule for nginx

location / {
    	rewrite ^/([a-zA-Z0-9_-]+)\.txt$ /index.php?name=$1;
    }

When sending from the site using the GET method of the " name " parameter, the url looks like /index.php?name=test
How to make the url look like /test when sending a GET request

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KorsaR-ZN, 2014-09-05
@KorsaR-ZN

At you for certain in the form there is simply action="".
Make it in JS so that the action attribute of the form is assigned dynamically depending on the parameters and conditions, as you need.

H
HAbRAhabp, 2015-11-02
@HAbRAhabp

$path = "http://example.com/index.php";
if (isset($_GET['name'])) header("Location: {$path}/{$_GET['name']}");
$url = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
// /index.php/test в переменной будет test
// парсит все, что идет после последнего слэша
// редирект не тестил

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question