2011-08-18 116 views
0

嗨,我用htaccess總共niewbie。 在我的網站(mysite.com)上,我收到了一個指向變量並將變量發送到安全站點上的頁面的鏈接(othersite.com/somepage.php?urlink='www.mysite.com')。htaccess網址掩碼

我該如何編輯我的htaccess文件來重寫someoneite.com/somepage.php?urlink='www.mysite.com'以使urlink擁有的任何價值。

我有這個在我的htaccess

Options +FollowSymlinks<br> 
Options All -Indexes<br> 
Options Indexes Includes FollowSymLinks ExecCGI 
RewriteEngine on 
RewriteRule ^&urlink=(.*) http://$1 [P] 

回答

-1

好奇。認爲它不會那樣工作;如果您在其他服務器上請求頁面,則您自己的htaccess不會爲您提供解決方案。 (如果你自己訪問/擁有othersite.com,他們的htaccess可以做到這一點)。

相反,我會使用HTTP_HEADER編寫一個小的PHP文件重定向到otherside.com。 因此,你可以告訴你的htaccess隱藏你的php-Url。

我以正確的方式理解你的問題嗎?

<?php 
$myInputURL = $my_POSTURL; 
$myOtherSite = "http://www.otherside.com?urllink="; 
$myURL = $myOtherSite . $myInputURL; 
header("Location: ".$myURL); 
?> 
+0

我確實可以訪問othersite.com。我提供的htaccess位於othersite.com上。 – clay

-1

RewriteRule不能直接處理查詢字符串。

例如,如果URL是http://www.example.com/kitten.php?say=meow,那麼RewriteRule只能匹配kitten.php部分。其他所有內容都可以通過RewriteCond進行匹配,例如:RewriteCond %{QUERY_STRING} ^urlink=(.*)

請參閱文檔:http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond


在你的情況下,它可以是這樣的(對不起,我不知道你想實現什麼,所以我只是修改現有規則) :

Options Indexes Includes FollowSymLinks ExecCGI 
RewriteEngine on 

RewriteCond %{QUERY_STRING} ^urlink=(.+)$ 
RewriteRule ^somepage\.php$ http://%1 [P] 
+0

感謝幫助傢伙。這是我想要做的。每當頁面顯示https://www.amazingbiz.co.za/eshop/shopping/cart_view.php?code=e618&urlink="www.mysite.com「時,它必須在地址欄中顯示www.mysite.com – clay

+0

你的意思是 - 用戶應該被重定向到「http:// www.mysite.com」? – LazyOne

+0

沒有。我在http://www.mysite.com上有產品頁面,但要查看購物車,您必須訪問https://www.amazingbiz.co.za/eshop/shopping/cart_view.php?code=e618&urlink=www .mysite.com。我想要的是爲購物車網頁網址顯示產品頁面的網址,如http://www.mysite.com/view_cart.php。看起來像是它不可能做到 – clay