用 .htaccess 重写动态 url

Rewrite a dinamic url with .htaccess

你好,我是 htaccess 的菜鸟,我有一个小问题。

我有这个 URL 我的网站。com/index.php/url

我没有任何代码可以解决这个问题,我在堆栈中搜索但没有任何帮助我:/

如何在用户输入时重定向网站

mysite.com/index.php/packages TO mysite.com/packages ?

Or some other ex. mysite.com/index.php/repos TO mysite.com/repos

谁能帮我解决这个问题谢谢!!显然了解规则是如何运作的!

将其放入您的 .htaccess 文件中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php/(.*)$ /index.php?folder= [QSA]

在您的 index.php 文件中:

<?php
if (isset($_GET['folder']))
{
    header('Location: /' . $_GET['folder']);
}