我使用的是一个前端控制器,它使用如下URL:
http://www.domain.com/index.php?action=main.Main,其中"main"是模块,"main"是操作。
对于URL重写,我在htaccess中使用这一行:
RewriteRule ^([^/]+)'.html$ index.php?action=$1 [QSA]
这导致http://www.domain.com/main.Main.html
现在,我如何用斜线替换模块和操作之间的点,使结果如下所示:http://www.domain.com/main/Main?
然后试试这个:
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
RewriteRule ^(.*)/(.*)$ index.php?module=$1&action=$2 [QSA]