Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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

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 重写htaccess目录以充当外部网站_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 重写htaccess目录以充当外部网站

Apache 重写htaccess目录以充当外部网站,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,所以我有一个网站,例如http://example.com/和另一个http://example.myeshop.com/。我想创建可访问的URLhttp://example.com/eshop与http://example.myeshop.com/,但没有重定向。当有人使用类似http://example.com/eshop/contact其效果与http://example.myeshop.com/contact等等。这是我的.htaccess文件: IndexIgnore */* Rew

所以我有一个网站,例如
http://example.com/
和另一个
http://example.myeshop.com/
。我想创建可访问的URL
http://example.com/eshop
http://example.myeshop.com/
,但没有重定向。当有人使用类似
http://example.com/eshop/contact
其效果与
http://example.myeshop.com/contact
等等。这是我的
.htaccess
文件:

IndexIgnore */*

RewriteEngine On

RewriteRule /eshop/(.*) http://example.myeshop.com/$1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/xhtml text/html text/plain text/xml text/javascript application/x-javascript text/css
</IfModule>

FileETag none
IndexIgnore*/*
重新启动发动机
重写规则/eshop/(*)http://example.myeshop.com/$1[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.php
AddOutputFilterByType DEFLATE text/xhtml text/html text/plain text/xml text/javascript应用程序/x-javascript text/css
FileTag无

但似乎不起作用。你能帮我怎么做吗?

你要找的是mod proxy。在服务器上启用代理模块,然后您可以使用:

RewriteEngine on

RewriteRule ^eshop/(.*)$ http://example.myeshop.com/$1 [P]

这将在内部将example.com的所有请求转发到example.myeshop.com。如果代理模块未启用,您将收到一个内部服务器错误。

如果您有权访问httpd.conf,您可以在httpd.conf文件中使用以下规则,其中提到了
mod_proxy
的部分,或者您可能必须放入
extra/httpd ajp.conf

ProxyPass /eshop/ http://example.myeshop.com/
ProxyPassReverse /eshop/ http://example.myeshop.com/
这两行应该在
httpd.conf
文件中取消注释

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

您好,我认为op希望在eshop之后开始代理/so规则应该是这样的
RewriteRule^eshop/(*)$http://example.myeshop.com/$1[P]
还是不行?它对我不起作用,也不会出错。我不知道我做错了什么。不幸的是,我没有访问该文件的权限。好吧,那么你确定你启用了mod proxy。实际上我不知道如何检查它。你必须让托管提供商确认你的
.htaccess
有访问mod_proxy的权限。可以通过DNS进行重写吗?