Php htaccess中主机名的重定向规则
让,Php htaccess中主机名的重定向规则,php,.htaccess,redirect,Php,.htaccess,Redirect,让,$staging\u 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] Re
$staging\u 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\u url时,它会重定向到$mobile\u url。但是,当我点击$staging\u url/design?id=23时。它再次重定向到$mobile\u url,我希望它重定向到$mobile\u url/design?id=23
提前谢谢。我使用变量来定义我的链接,因为堆栈溢出只允许少于10个用户使用2个链接。
我的.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]
如中所述,您可以使用Paranthesis获取请求URL的某些部分,并在稍后引用它们,例如:
^/somepath(.*) /index.php?page=$1
变化本身就是个问题我想你的IP在这两种情况下都是一样的?只需忽略它们,使用相对路径应该可以很好地工作!做了改变,还是不起作用。我做错了什么,我的意思是从浏览器打开我的网站,它甚至没有重定向。ReWriteCond是否真的有效?尝试重定向。*到谷歌(或其他什么),看看是否有任何事情发生。我还注意到你说你有一个
htaccess
文件,它应该是.htaccess
,但也许这只是问题中的一个输入错误?如果不起作用,可以使用phpinfo()检查mod_rewrite模块是否已启用。我已添加了.htaccess文件。文件名为.htaccess。mod_重写已启用。你能看一下.htaccess文件吗?如果有什么问题,请更正它。