mod_rewrite:内部重写为(假)干净的URL不可能。

这更是一个为什么问题。

我正在使用CMS,通过开箱即用的mod_rewrite处理干净的URL。

网站有一个部分/accessories ,现在必须重新命名为/store

在懒惰模式下,我只是想使用mod_rewrite进行内部重写,因此,在访问example.com/store/ ,我希望透明地从example.com/accessories内容,而不需要任何外部redirect。

到目前为止,我已经试过这个:

 RewriteEngine On # Internally rewrite /store to /accessories RewriteRule ^store /accessories [L] #also tried with other flags like PT, N, C # All below rules are provided by CMS RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) - [PT,L] RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*) index.php 

没有任何工作

我能做到这一点的两条途径是:

  • 通过内部重写请求到其相应的“凌乱”的URL,如下所示:

    RewriteRule ^store /index.php?s=accessories [L]

  • 通过使用mod_proxy和ProxyPass指令(我将其作为解决scheme丢弃,因为mod_proxy在生产服务器上不可用)。

我刚刚得出的结论是,URL不能在内部重写为其他(假的)干净的URL,同时保持重写链接活着。 “假”我的意思是不是真正的文件系统path(通常,文件夹)或真正的文件(如index.php)的URLpath。

所以,问题是:为什么?