перезапись URL на синтакс с .htaccess - PullRequest
0 голосов
/ 09 мая 2018

Я на Apache 2, и я бы знал, если мой htacces правильный

мой URL, например:

localhost/test/boutique/index.php
localhost/test/boutique/index.php/language,en
localhost/test/boutique/index.php/Products/Description/products_id,1
localhost/test/boutique/index.php/Products/Description/products_id,2/language,fr

Каков наилучший подход для хорошего URL, как указано выше Предположим, что index.php должен отключиться, чтобы получить нечто подобное

localhost/test/boutique/Products/Description/products_id,1

Я пробую это, но это не работает

  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(.*)$ http://localhost/test/boutique/index.php/$1 [PT,L]

1 Ответ

0 голосов
/ 09 мая 2018

Предполагая, что /test/boutique/ является настоящим каталогом, вы можете использовать эти правила внутри /test/boutique/.htaccess:

RewriteEngine On
RewriteBase /test/boutique/

# remove index.php if entered directly by clients
RewriteCond %{THE_REQUEST} /index\.php/(\S*)\s [NC]
RewriteRule ^ %1 [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!index\.php$).* index.php/$0 [L,NC]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...