我目前使用此代码通过使用文件名作为get参数来静默调用另一个php文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} blog/([^/]+)/?$ [NC]
RewriteRule .* repost_p.php?post=%1 [L]
如果我想将文件名设为假子目录,并将文件名添加为第二个get参数,该怎么办?
我该怎么做呢?
答案 0 :(得分:0)
你可以使用类似的东西:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog/(.*) /repost_p.php?path=$1 [L]
然后在repost_p.php文件中,您可以过滤路径变量以找出子目录。
$path = isset($_GET['path']) ? $_GET['path'] ? '';
$params = explode('/', $path);
//params is now an array with all subdirectories.
//Make sure you validate each one for valid input! This can also be used for sql injection