Php 使用正则表达式在URL中用斜杠替换点

Php 使用正则表达式在URL中用斜杠替换点,php,regex,.htaccess,Php,Regex,.htaccess,我使用的前端控制器使用URL如下: ,, 其中,“main”是模块,“main”是动作 对于URL重写,我在htaccess中使用这一行: RewriteRule ^([^/]+)\.html$ index.php?action=$1 [QSA] 这导致 现在,如何用斜线替换模块和操作之间的点,使结果如下所示: ?试试这个: RewriteRule ^(.*)/(.*)$ index.php?action=$1.$2 [QSA] 试试这个: RewriteCond %{REQUEST_UR

我使用的前端控制器使用URL如下:

,, 其中,“main”是模块,“main”是动作

对于URL重写,我在htaccess中使用这一行:

RewriteRule ^([^/]+)\.html$ index.php?action=$1 [QSA] 
这导致

现在,如何用斜线替换模块和操作之间的点,使结果如下所示: ?

试试这个:

RewriteRule ^(.*)/(.*)$ index.php?action=$1.$2 [QSA]
试试这个:

RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)/(.*)\.html$ /$1.$2.html [L]

RewriteCond %{REQUEST_URI} \.html$
RewriteCond %{REQUEST_URI} !/.+/
RewriteRule ^([^/]+)\.html$ index.php?action=$1 [L,QSA] 

这将接受如下请求:
http://www.domain.com/main/something/action/Main.html
并将URI重写为:
/index.php?action=main.something.action.main

您建议我将模块和操作分离为单独的变量,那么您的答案就有意义了。然而,在我的例子中,我只有一个变量$1,它是'module.action',我想用斜线替换这个点。
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)/(.*)\.html$ /$1.$2.html [L]

RewriteCond %{REQUEST_URI} \.html$
RewriteCond %{REQUEST_URI} !/.+/
RewriteRule ^([^/]+)\.html$ index.php?action=$1 [L,QSA]