我有一些凌乱的旧网址,比如......
http://www.example.com/bunch.of/unneeded/crap?opendocument&part=1
http://www.example.com/bunch.of/unneeded/crap?opendocument&part=2
...我想重定向到更新,更清洁的形式......
http://www.example.com/page.php/welcome
http://www.example.com/page.php/prices
我知道我可以通过简单的重定向将一个页面重定向到另一个页面,即
重定向301 /bunch.of/unneeded/crap http://www.example.com/page.php
但源页面不会改变,只有它是GET变量.我无法弄清楚如何将重定向基于这些GET变量的值.任何人都可以帮忙!?我对旧的正则表达方式非常方便,所以如果必须的话我可以使用mod-rewrite,但是我不清楚重写GET变量的语法,我宁愿避免性能损失并使用清除Redirect指令.有办法吗?如果没有,任何人都可以提出正确的mod-rewrite语法?
干杯,
罗杰.
这个phpinfo()演示了这个问题.
我正在向URL传递一个查询字符串:
?qwerty=asdfg
Run Code Online (Sandbox Code Playgroud)
因此,我希望它列出这两个PHP变量:
_REQUEST["qwerty"] asdfg
_GET["qwerty"] asdfg
Run Code Online (Sandbox Code Playgroud)
还有这个查询字符串:
_SERVER["QUERY_STRING"] qwerty=asdfg
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用.似乎根本没有设置这些变量.
我正在使用lighttpd.这可能与问题有关,也可能与此无关,但我的greengar.com-lighttpd.conf看起来像这样,因为我在大多数域名网页上使用WordPress:
### Generated by Elliot
### Wordpress: http://www.greengar.com
url.rewrite += (
"^/(wp-.+).*/?" => "$0",
"^/(blog/wp-.+).*/?" => "$0",
"^/(.*.php)" => "$0",
"^/(.*.pdf)" => "$0",
"^/(.*.png)" => "$0",
"^/(.*.html)" => "$0",
"^/(.*.ico)" => "$0",
"^/(.*.gif)" => "$0",
"^/(.*.txt)" => "$0",
"^/(images).*/?" => "$0",
"^/(sitemap.xml)" => "$0",
"^/(xmlrpc.php)" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)
Run Code Online (Sandbox Code Playgroud)
同样,我不确定这是否与问题有关.
我的问题是:为什么PHP看不到查询字符串?
我该如何解决?
这是一个普通的phpinfo(),可以成功查看查询字符串.这是在运行Apache的其他服务器上运行的.
我正在使用ASP.NET和我的网站的成员资格提供程序.如果用户能够轻松查看其GUID,那么这会被视为安全风险吗?我是否应该采取额外措施来阻止用户轻松找到他们的GUID,例如在他们确认验证过程时.虽然有很多方法可以解决这个问题,例如对"前端"活动使用单独的GUID,这是否会增加开销和开发时间?
可能的欺骗的一个例子是我在验证用户访问资源的权限时.
Guid cUser = (Guid)Membership.GetUser().ProviderUserKey; //if this is publicly viewed, then there's no reason to call the DB or store in a session as it can be placed in the QueryString
bool grantAccess = CheckGroupPermission(cUser, groupID);
Run Code Online (Sandbox Code Playgroud)
谢谢
我在Windows Phone 7中有一个简单的用户控件,我想从用户控件构造函数中访问查询字符串集合.我已经尝试了很多方法,似乎无法访问包含XAML的查询字符串集合.
基本上我正在导航到页面,我的用户控件将访问查询字符串值以将值写回接口.
我错过了添加程序集或引用或其他内容吗?
对于一个新网站,我有一个非常好的(迄今为止)wordpress的设置.漂亮的网址按预期工作.
我有一个动态页面,根据查询字符串加载内容:
/dynamic/?loc=england&code=uk
Run Code Online (Sandbox Code Playgroud)
我希望这个URL"漂亮",但每次我修改.htaccess都没有做出任何更改.尝试了一切,谷歌搜索其他一切 - 最后的手段.如果我能得到以下工作,那么我会很高兴.
我需要让URL看起来像.
/dynamic/location/england/code/uk/
Run Code Online (Sandbox Code Playgroud)
将此添加到任何.htaccess会破坏整个网站.
RewriteRule /dynamic/(.*)/(.*)/(.*)/(.*)/$ /dynamic?$1=$2&$3=$4
Run Code Online (Sandbox Code Playgroud)
我错过了什么.
提前致谢
ñ
在HTML页面上,我引用了一个外部Javascript文件,如下所示:
<script src="http://MyServer.com/js/myscript.js?Happy=True"></script>
Run Code Online (Sandbox Code Playgroud)
在myscript.js运行时,我可以获得js源URL中的Happy = True QueryString一部分吗?
注意我不想要HTML页面的URL,我需要获取js文件的URL.
我的猜测是否定的.
我有3个具有不同结构的href,并且它们都具有相同的硬编码参数(在此示例中值= somevalue-abc).
如何更新链接并使用新值覆盖值?
jQuery的
$(document).ready(function () {
$('a').click(function () {
var $newValue = 'newvalue';
//here a function that overwrites the parameter 'somevalue-abc' with $newValue
});
});
Run Code Online (Sandbox Code Playgroud)
HTML
<a class="demo" href="http://www.mydomain.com/page.aspx?demo&value=somevalue-abc">link 1</a>
<a class="real" href="http://www.mydomain.com/?value=somevalue-abc#go=yes">link 2</a>
<a class="outgoing" href="http://www.mydomain.com/page.aspx?value=somevalue-abc">link 3</a>
Run Code Online (Sandbox Code Playgroud) 我如何传递带有特殊字符的查询字符串?
例如,我需要在我的查询字符串中传递"&",如下所示:
../solrresults.asp?mode=search&data=M & S
Run Code Online (Sandbox Code Playgroud) 我在这里结束了我的智慧,我很肯定这是一个荒谬的打字错误,或者我忘了写点什么.
无论如何,我试图将数据从twitter引导模式内的表单发送到一个名为'processed.php'的文件,该文件使用PHPMailer脚本.但是,当我提交表单时,没有数据传递给查询字符串,url只是更改为'/processed.php?'
如果有人能够对它有所了解,我会非常感激.
这是代码:
HTML第一:
<div class="modal-body">
<form id="send-msg" method="GET" action="processed.php">
<fieldset>
<div class="control-group">
<label class="control-label" for="inputNavn">Navn:</label>
<div class="controls">
<input type="text" class="input-medium required" id="inputNavn">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputTlf">Telefon nummer:</label>
<div class="controls">
<input type="text" class="input-medium required" id="inputTlf">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputMsg">Besked:</label>
<div class="controls">
<textarea class="input-large required" id="inputMsg" rows="3"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary btn-large" id="inputSend" href="#" rel="popover" data-content="Vi vender tilbage hurtigst muligt." data-original-title="Send besked" data-loading-text="Sender besked…">Send besked</button>
</div>
</div>
</fieldset> …Run Code Online (Sandbox Code Playgroud) 我有一个控制器的动作:
public ActionResult Find(IEnumerable<string> ids) { ... }
Run Code Online (Sandbox Code Playgroud)
我成功地通过路线调用它../Find?ids=01&ids=02&ids=03.DefaultModelBinder轻松绑定参数,无需额外配置.但是,当我尝试进行出站路由时,即在我的视图中使用这样的代码
@Url.Action("Find", "Grid", new {ids=new List<string>{01,02,03}})
Run Code Online (Sandbox Code Playgroud)
.. ..?ids=System.Collections.Generic.List1[System.String]我的URL中有一个很好的查询字符串.我已经找到了一些建议编写自定义绑定/路由的答案,但我相信这样一个简单的任务应该更容易解决而无需任何额外的代码.
PS:我非常乐意改变我的查询字符串格式,我只想依靠一些默认的框架行为来完成任务:在querystring中传递一个数组.
简短版本:使用查询字符串中的数组呈现控制器操作链接的最简单方法是什么?
query-string ×10
php ×3
.htaccess ×2
asp-classic ×1
asp.net ×1
asp.net-mvc ×1
encode ×1
forms ×1
guid ×1
html ×1
javascript ×1
jquery ×1
membership ×1
mod-rewrite ×1
parameters ×1
rewrite ×1
routing ×1
security ×1
url ×1
wordpress ×1