[英]Apache mod_rewrite not redirecting to PHP, but redirecting to other URLs
[英]Apache : Redirecting with mod_rewrite
我正在尝试将本地URL重定向为指向生产URL,但是,我运气不佳。
这是我在.htaccess文件中写的,
RewriteRule "^http://local.production/sites/all/styles/(.*)$" "http://www.production.com/sites/all/styles/$1"
提前谢谢了。
在
Directory
和htaccess上下文中,在删除将服务器引导至当前RewriteRule
的前缀(例如,“ app1 / index.html”或“ index.html”,具体取决于指令的位置)之后, Pattern将首先与文件系统路径进行匹配。定义)。 如果希望与主机名,端口或查询字符串匹配,请分别将RewriteCond与%{HTTP_HOST}
,%{SERVER_PORT}
或%{QUERY_STRING}
变量一起使用。
因此,这可能是您需要的:
RewriteCond %{HTTP_HOST} ^local.production$
RewriteRule "^sites/all/styles/(.*)$" "http://www.production.com/sites/all/styles/$1"
请尝试以下代码:
Redirect http://local.production/sites/all/styles/(.*)$ h http://www.production.com/sites/all/styles/$1
请参阅: https : //mediatemple.net/community/products/grid/204643080/how-do-i-redirect-my-site-using-a-htaccess-file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.