[英]URL Rewrite for a subdomain hiding the redirection
我正在使用 symfony 框架进行一些 PHP 开发,它对不同的站点使用相同的代码库。 这需要我做一些 htaccess 重写,这给我带来了一些痛苦。
developer.php
developer.mysite.com
我想要做的是将developer.mysite.com
的所有内容重写为www.mysite.com/developer.php/$1
。 但是,在 url 中,我仍然希望它说developer.mysite.com/$1
我现在重定向以下代码并且不保留原始 url:
RewriteCond %{HTTP_HOST} ^developer\.mysite\.com$ [NC]
RewriteCond %{REQUEST_URI} !\..+$
RewriteRule ^(.*)$ http://www.mysite.com/developer.php/$1 [NC,L]
您是将developer.mysite.com
别名为mysite.com
还是它有自己的 public_html (或 httpdocs;无论 webroot 是什么......)文件夹?
我认为最简单的解决方案是将developer.mysite.com
指向服务器上的mysite.com
,以便它们共享相同的 public_html 文件夹。
main.php
。developer.php
。index.php
将查看$_SERVER['SERVER_NAME']
以确定并包含适当的前 controller。免责声明:我不熟悉 symfony 的运作方式。 我假设它有一个前面的 controller 就像其他框架一样。
我认为最好为您的应用程序制作单独的目录。 我举例说明我是如何实现这个任务的:
<VirtualHost *:80>
DocumentRoot "/path/to/poject/web"
ServerName domain.dev
Alias /sf C:/xampp/php/PEAR/data/symfony/web/sf
<Directory "/path/to/poject/web">
#php_admin_value mbstring.func_overload 7
AllowOverride All
Allow from All
</Directory>
<Directory "C:/xampp/php/PEAR/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/path/to/poject/web_developer"
ServerName developer.domain.dev
Alias /sf C:/xampp/php/PEAR/data/symfony/web/sf
<Directory "/path/to/poject/web_developer">
#php_admin_value mbstring.func_overload 7
AllowOverride All
Allow from All
</Directory>
<Directory "C:/xampp/php/PEAR/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
Alias /css /path/to/poject/web/css
<Directory "/path/to/poject/web/css">
AllowOverride All
Allow from All
</Directory>
Alias /images /path/to/poject/web/images
<Directory "/path/to/poject/web/images">
AllowOverride All
Allow from All
</Directory>
Alias /js /path/to/poject/web/js
<Directory "/path/to/poject/web/js">
AllowOverride All
Allow from All
</Directory>
Alias /sfDoctrinePlugin /path/to/poject/web/sfDoctrinePlugin
<Directory "/path/to/poject/web/sfDoctrinePlugin">
AllowOverride All
Allow from All
</Directory>
Alias /sfFormExtraPlugin /path/to/poject/web/sfFormExtraPlugin
<Directory "/path/to/poject/web/sfFormExtraPlugin">
AllowOverride All
Allow from All
</Directory>
Alias /uploads /path/to/poject/web/uploads
<Directory "/path/to/poject/web/uploads">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
web_developer
目录通常是 sf1.4 项目的 web 目录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.