Как получить доступ к index.php каталога без косой черты и не получить 301 перенаправлениеPhp

Кемеровские программисты php общаются здесь
Гость
Как получить доступ к index.php каталога без косой черты и не получить 301 перенаправление

Сообщение Гость »


У меня есть такая структура:

Код: Выделить всё

site.com/api/index.php
. When I send data to

Код: Выделить всё

site.com/api/
there is no issue, but I imagine it would be better if the api would work without the trailing slash also, like this:

Код: Выделить всё

site.com/api
. This causes a 301 redirect and thus loses the data (since data isn't forwarded). I tried every re-write I could think of and couldn't avoid the redirect. This is my current re-write rule (though it may be irrelevant).

Код: Выделить всё

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*)$ api/index.php [L]
Can I make this url work and maintain the post data without using the trailing slash?

Some rewrites that didn't work: (all still redirect)

Код: Выделить всё

RewriteRule ^api$ api/index.php [L]
RewriteRule ^api/*$ api/index.php [L]


Источник: https://stackoverflow.com/questions/186 ... et-301-red

Вернуться в «Php»