如何在index.php
中使用mod_rewrite?通常我使用此代码:
RewriteRule ^page/([^-]*)/([^-]*)$ /page.php?xxx=$1&yyy=$2 [L]
并加载页面www.example.com/page/11111/2222222
。
这可以按预期工作。但现在我想应用.htaccess
以这种格式使用网址:www.example.com/11111/2222222
并使用page.php
中的所有代码。
我该怎么做?
答案 0 :(得分:1)
简单,从规则中删除page/
并使用以下方式:
RewriteRule ^([^-]*)/([^-]*)$ /page.php?xxx=$1&yyy=$2 [L]
答案 1 :(得分:0)
试试这个
在.htacces
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+/?)$ page.php?url=$1 [NC]
然后,在page.php中:
$params = explode("/", $url);
//$params[0] = '11111', $params[1] = '2222222', and so on....