我有多个域名都指向同一服务器,并且我正在寻找一种方法来从每个域名访问单个位置中的一组脚本作为一种共享资源。
例如
http://abcdeals.com/shared-resource/
http://defdeals.com/shared-resource/
http://hijdeals.com/shared-resource/
全部使用/home/zdeals/public_html/shared-resource/中的相同文件
<小时/>完整详细信息:
“共享资源”文件位于以下服务器路径
/home/zdeals/public_html/shared-resource/
多个域名,例如(abcdeals.com、defdeals.com 和 hijdeals.com)位于以下服务器路径
/home/abcdeals/public_html/
/home/defdeals/public_html/
/home/hijdeals/public_html/
理想情况下,我希望能够访问共享资源文件,而无需通过访问来重定向用户
http://abcdeals.com/shared-resource/
http://defdeals.com/shared-resource/
http://hijdeals.com/shared-resource/
我一直在研究alias和mod_rewrite,但没有结果。 我在/home/abcdeals/public_html/.htaccess 中尝试过的一些事情
AliasMatch ^/shared-resource(.*) /home/zdeals/public_html/shared-resource$1
或
RewriteRule ^shared-resource/(.*) home/zdeals/public_html/shared-resource/$1 [L]
...还有更多类似的
访问 http://abcdeals.com/shared-resource/时,我收到 500 内部服务器错误或 404 未找到错误
如果有帮助的话,我还可以访问 httpd.conf 文件。
现有的.htaccess文件如下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
#RewriteBase /
RewriteRule . index.php [PT]
RewriteRule ^(system/(classes|locale|schema|$)) index.php [PT]
我将永远感激对此的任何帮助。
最佳答案
您可以为此使用符号链接(symbolic link)。在 Linux 中,您可以通过以下方式执行此操作:
ln -s /home/zdeals/public_html/shared-resource/ /home/abcdeals/public_html/shared-resource/
这会创建一个符号链接(symbolic link)/home/abcdeals/public_html/shared-resource/-->/home/zdeals/public_html/shared-resource/
关于php - 共享 php 脚本的别名、mod_rewrite 或其他名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9846536/