2017-08-03 86 views
0

我已經通過了很多關於apache的教程,並可以重定向幾個網址。 雖然,有這個url我需要做一個重定向,我不能。任何幫助將不勝感激!謝謝 ! 注:進行更改的httpd.conf通過apache重定向的URL

網址:https://example.com/common/webScript.jsp?path=/example/content/latest.rss?section=Insight%26type=Leadershttps://example.com

正如我已經配置了我的域名,就需要重定向 網址:/common/webScript.jsp?path=/example /content/latest.rss?section=Insight%26type=Leaders至/

回答

0

「?」之後的uri路徑字符是查詢字符串,您需要使用%{QUERY_STRING}^path`或類似的方法檢查它們。粗糙例如:

# to capture uri-path with query string starting with "path..." 
# redirect it to/

# for 2.4 with If directive (most modern) 
<If "%{QUERY_STRING} =~ m#^path#"> 
    RedirectMatch ^/
</If> 


# or with mod_rewrite that works with 2.2 too  
RewriteEngine on 
RewriteCond %{QUERY_STRING} ^path 
RewriteRule ^/[R,L,QSD] 

如果你只是想/common/webScript.jsp重定向到/ 只是做一個簡單:

RedirectMatch ^/common/webScript.jsp/
+0

太好了!謝謝 !但我不想用查詢字符串「path」來標識url,但想要確定url是否以/common/webScript.jsp開頭。如果網址以/common/webScript.jsp開頭,想要重定向到/ –

+0

@ShailajaKrishnamurthy根據您的評論添加了一個新選項。 –

+0

HI @ ezra-s,這工作正常!謝謝!但除了RewriteCond,使用RewriteRule而不是RedirectMatch,它工作正常! –