php - 共享 php 脚本的别名、mod_rewrite 或其他名称?

标签 php linux .htaccess mod-rewrite alias

我有多个域名都指向同一服务器,并且我正在寻找一种方法来从每个域名访问单个位置中的一组脚本作为一种共享资源。

例如

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/

相关文章:

python - 在Python中调用UNIX命令(nice、renice)

php - 抱歉,无法找到您要查找的页面。硅胶错误

PHP array_slice - 如何获得没有切片项目的原始数组

php - 删除记录返回 SQLSTATE[42000] 错误

php - Hackerrank在php中绘制长度为N的楼梯

.htaccess - 重定向到 Lumen (Laravel) 上的公用文件夹

php - 如何让 Facebook Debugger 读取规范 URL?

php - 将 PDO 数据库对象实例传递给其他类函数

linux - 意外删除位于/usr/include/GL 的 GL 文件夹

ruby-on-rails - 为 Rails 应用程序设置 httpd.conf