2015-09-20 20 views
1

我有一個使用付款API的腳本,付款成功後將用戶發送到鏈接並腳本驗證付款。在mode_rewrite規則中作出例外

但我開始使用mod_rewrite使URL友好。編輯.htaccess許多用戶給我發電子郵件,並說他們的付款已添加到他們的帳戶。

我正在使用此規則。

# Redirect "ugly" URLs to the desired URLs 
RewriteCond %{THE_REQUEST} \?a=([^\ ]*) 
RewriteRule ^$ /%1? [R=301,L] 

# Internally rewrite the "pretty" URL to the real URL 
RewriteCond %{QUERY_STRING} ^$ 
RewriteCond %{THE_REQUEST} !/admin.php [NC] 
RewriteRule ^([^/]*)$ /?a=$1 [L] 

它basicaly改寫hort.com/?a=pagehort.com/page

付款接受鏈接

hort.com/index.php?a=return_visa&process=yes 

而且這一

hort.com/?a=return_visa&process=yes 

我想要的東西添加到我的規則來阻止edithing這個鏈接。

+0

喜先生。你能看看這個嗎? @anubhava – jimuty

+0

'hort.com/?a = return_visa&process = yes'是否應該重定向到'hort.com/return_visa'? – anubhava

+0

沒有。它不應該。第一個環節接受來自美國的簽證來自俄羅斯銀行。 – jimuty

回答

1

嘗試下列規則:

# Redirect "ugly" URLs to the desired URLs 
RewriteCond %{THE_REQUEST} \?a=([^&\s]+)\s 
RewriteRule ^(index\.php)?$ /%1? [R=301,L] 

# Internally rewrite the "pretty" URL to the real URL 
RewriteCond %{QUERY_STRING} ^$ 
RewriteCond %{THE_REQUEST} !/admin\.php [NC] 
RewriteRule ^([^/.]+)/?$ ?a=$1 [L,QSA] 
+0

我在Apache 2.2上! qsa不支持! :D – jimuty

+0

'QSA'在Apache 2.2上運行得非常好,但是您可以從最後一條規則中刪除'QSA'。 – anubhava

+0

有些事情似乎錯了爲什麼我應該重寫規則^(index \ .php)?$ /%1? [R = 301,L]?還有另外一個頁面沒有使用index.php文件。它可能會損害他們。像從hort.com/support – jimuty

0

您可以更改第一個重定向:

# Redirect "ugly" URLs to the desired URLs 
RewriteCond %{THE_REQUEST} \?a=([^\ ]*) 
RewriteCond %{THE_REQUEST} !\?a=return_visa [NC] 
RewriteRule ^$ /%1? [R=301,L] 
+0

沒有幫助。但是謝謝。我認爲第二場比賽會導致這個問題。不是第一個。 – jimuty