这是我的.htaccess文件:
# To remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L]
# To remove .php extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC]
RewriteRule ^ %1 [R=301,L]
# To check whether the PHP file exists and set it back internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L]
# To redirect /index to root
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
假设根目录中有一个file.php,v1,v2,...是我的查询字符串输入,请求下面的URL:
http://domain.tld/file/v1/v2...
我只需要使用.htaccess将v1,v2,...作为HTTP GET发送到file.php,它应该与任何其他PHP文件名一起使用,并且如果可能有任意数量的输入,否则处理最多3输入就足够了。
答案 0 :(得分:1)
我认为RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)/(.+)$ $1.php?params=$2 [NC,L]
只是一个模板名称,并不仅限于该特定名称。你可以尝试:
file.php
现在,在$_GET['params'] // which will be of the form v1/v2/v3...
中,您将获得传递的查询参数:
let ownerId = NSUserDefaults.standardUserDefaults().objectForKey("cloudkitUserReccordID") as! String
let ownerRef = CKReference(recordID: CKRecordID(recordName: ownerId), action: CKReferenceAction.None)
let predicate = NSPredicate(format: "ownerRecord != %@, forSale = 1", ownerRef)
let query = CKQuery(recordType: "Item", predicate: predicate))