如何更改网址而不更改文件夹?

use*_*187 3 php smarty url-routing

我在我的网站上使用MVC框架.在我的网页中没有显示URL文件扩展名.我需要指定文件扩展名

www.legacy.com/women/tops.php 
Run Code Online (Sandbox Code Playgroud)

但它只显示

www.legacy.com/women/tops/ 
Run Code Online (Sandbox Code Playgroud)

为seo目的我想改变扩展名的网址.但我无法更改文件夹或文件名.

我还有一个疑问.我的网页正在显示

www.legacy.com/women/tops/ 
Run Code Online (Sandbox Code Playgroud)

像这样我想改变这个www.legacy.com/women_tops.php/有可能吗?

谢谢

这是我用来将URL与控制器相关联的代码:

$arrCommands = array (
    'home' => "contents",
    'members' => "",        
);

if ( $arrCommands[$command1] == "*" )
{
    $includeFile = CONTROLLER_PATH . "/" . $command1 . "/" . $command2 . ".php";

    if ( !file_exists($includeFile) )
        $includeFile = CONTROLLER_PATH . "/" . $command1 . "/default.php";
}
    elseif ( !array_key_exists($command1, $arrCommands) )
    {
        $includeFile    =   CONTROLLER_PATH . "/contents/" . $command1 . ".php";
        if ( !file_exists($includeFile))
    Header( "Location: http://metroplots.ragedev/404_error/" );     
    }
else
{
    $includeFile = CONTROLLER_PATH . "/". $arrCommands[$command1] . "/" . $command1 . ".php";

    if ( !file_exists($includeFile) )
        $includeFile = CONTROLLER_PATH . "/contents/home.php";
}

include_once($includeFile);
Run Code Online (Sandbox Code Playgroud)

Ale*_*lex 5

.htaccess可以做魔法.可以重写任何你想要的东西,可能会变得凌乱...... http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

您还应该能够在应用程序本身中执行此操作.在大多数好的框架中,您可以使用自定义路由,这里是zend示例.