Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache只重写域名,不重写主机名_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache只重写域名,不重写主机名

Apache只重写域名,不重写主机名,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我有以下资料: http://test.inside/index.html?something=big http://otherthing.inside/index.html?something=else “test”和“otherthing”可以是任何东西。我想捕获在http://和第一个句点之间键入的内容 RewriteRule ^/(.*)$ http://??.correct-domain.com/$1 [R,L] 我想把这些重定向到 http://test.correct-doma

我有以下资料:

http://test.inside/index.html?something=big
http://otherthing.inside/index.html?something=else
“test”和“otherthing”可以是任何东西。我想捕获在http://和第一个句点之间键入的内容

RewriteRule ^/(.*)$ http://??.correct-domain.com/$1 [R,L]
我想把这些重定向到

http://test.correct-domain.com/index.html?something=big
http://otherthing.correct-domain.com/index.html?something=else
这可能吗?我需要在VirtualHost语句中使用RewriteRule执行此操作

类似这样的东西,但我还需要捕获http://和第一个句点之间的第一部分

RewriteRule ^/(.*)$ http://??.correct-domain.com/$1 [R,L]

是的,很有可能。您可以在
文档\u ROOT/.htaccess
文件中使用此代码:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([^.]+)\.inside\. [NC]
RewriteRule ^ http://%1.correct-domain.com%{REQUEST_URI} [NE,R=301,L]

%1
是在
RewriteCond

@Jocker中捕获的
HOST\u NAME
中第一部分的反向引用:这只是链接到当前问题。