获取没有 index.php 的 URI 参数
Get URI params without index.php
我有一个 URL 喜欢 http://example.com/index.php/fruit/1a2b3c
我想获取我为其编写代码的 URI。
现在我想从可见的 URL 中删除 index.php,即使 URL 是 http://example.com/fruit/1a2b3c 它也应该工作并且它应该仍然指向 index.php
我在 apache2 上使用 PHP 7
将您的 .htaccess
文件更改为,
RewriteEngine on
RewriteCond !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [QSA,L]
希望这会奏效。
将以下代码添加到您的 .htaccess 文件中。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php? [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
我有一个 URL 喜欢 http://example.com/index.php/fruit/1a2b3c
我想获取我为其编写代码的 URI。
现在我想从可见的 URL 中删除 index.php,即使 URL 是 http://example.com/fruit/1a2b3c 它也应该工作并且它应该仍然指向 index.php
我在 apache2 上使用 PHP 7
将您的 .htaccess
文件更改为,
RewriteEngine on
RewriteCond !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [QSA,L]
希望这会奏效。
将以下代码添加到您的 .htaccess 文件中。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php? [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]