我需要做下面的,我不知道这是用PHP,Javacript或者如果它在htaccess文件所做的一切。
I need to do the following and I'm not sure if this is done with PHP, Javacript or if its done in the htaccess file.
当有人签署了我的网站上,他们得到了的WebID分配的,他们可以访问一个页面,我不想过没有说要的WebID访问某些内容。
When somebody signs up on my site they get a "webid" assigned and they can access a page with some content that i don't want to be accessed without that webid.
例: 1)游客签约 2)我将访问者这样的HTTP链接:// www.mysite.com/paid/report.php?webid=123456 3)访问者点击链接,查看报告
Example: 1) visitor signs up 2) I send the visitor a link like this http:// www.mysite.com/paid/report.php?webid=123456 3) visitor clicks on the link and views the report
但如果访问者输入HTTP:// www.mysite.com/paid/report.php没有的WebID参数我需要他们被重定向到不同的页面,例如:HTTP:// www.mysite。 COM / signup.php
but if the visitor enters http:// www.mysite.com/paid/report.php without the "webid" parameter I need them to be redirected to a different page, for example http:// www.mysite.com/signup.php
我假定这一点是需要在htaccess文件做了,但我不知道怎么样。
I'm assuming this is something that needs to be done in htaccess file, but I'm not sure how.
感谢你。
好了,你可以用的.htaccess像这样做
Well, you can do it with .htaccess like so
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/report.php$
RewriteCond %{QUERY_STRING} !^webid=([0-9]*)$
RewriteRule ^(.*)$ http://example.com/signup.php [R=302,L]
但为什么不使用PHP
but why not use PHP
<?php
if ( !isset( $_REQUEST['webid'] ) ){
// redirect
header( 'Location: http://example.com/signup.php' );
exit();
}
?>