[英]Redirect Rule for hostname in htaccess
設, $staging_url = http://xx.xx.xx.xx/
$mobile_url = http://xx.xx.xx.xx/mobile/xxx/testing
我在我的htaccess
文件中定義了這個重定向規則:
RewriteCond "%{HTTP_USER_AGENT}" "(android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos)" [NC]
RewriteRule "/(.*)$" "/mobile/xxx/testing/$1" [L]
當我從手機上點擊$ staging_url時 ,它會重定向到$ mobile_url 。 但是,當我點擊$ staging_url / design?id = 23時 。 它再次重定向到$ mobile_url ,我希望它重定向到$ mobile_url / design?id = 23
提前致謝。 我使用變量來定義我的鏈接,因為堆棧溢出只允許2個鏈接用於少於10個信譽的用戶。 我的.htaccess文件:
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet)
RewriteRule ^(.*)design$ story.php?id=$1 [L,QSA]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|ipad|iemobile" [NC]
RewriteRule ^(.*)$ http://google.com [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]
如mod_rewrite文檔中所述,您可以使用parantheses獲取所請求URL的某些部分,並在以后引用它們,例如:
^/somepath(.*) /index.php?page=$1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.