我正在使用URL重写,并具有特定的.htaccess配置一个应用程序。在应用程序工作时,我有三个eviorments:
在Developent我的本地机器(本地主机) 在分期(staging.mydomain.com) 生产(www.mydomain.com)我不断推新升级的分期和生产环境和每个I覆盖现有的源$ C $ C时候我已经在改走.htaccess文件。有没有一种方法可以让我在通用的.htaccess的目录,或者对其进行自动侦测到它的环境?
我目前的.htaccess文件如下。我只是取消注释的部分不同的环境之间,但希望能停止这样做......
#开发
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_URI}!= /的favicon.ico
重写规则^(。*)$ /app/index.php?request=$1 [L,QSA]
#分期
#RewriteEngine叙述上
#的RewriteCond%{} REQUEST_FILENAME!-f
#的RewriteCond%{} REQUEST_FILENAME!-d
#的RewriteCond%{REQUEST_URI}!= /的favicon.ico
#重写规则^(。*)$ /html/app/index.php?request=$1 [L,QSA]
#生产
#RewriteEngine叙述上
#的RewriteCond%{} REQUEST_FILENAME!-f
#的RewriteCond%{} REQUEST_FILENAME!-d
#的RewriteCond%{REQUEST_URI}!= /的favicon.ico
#重写规则^(。*)$ /index.php?request=$1 [L,QSA]
在此先感谢!
查
解决方案 #开发
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_URI}!= /的favicon.ico
的RewriteCond%{REQUEST_HOST} ^本地主机
重写规则^(。*)$ /app/index.php?request=$1 [L,QSA]
#分期
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_URI}!= /的favicon.ico
的RewriteCond%{REQUEST_HOST} ^ staging.mydomain.com
重写规则^(。*)$ /html/app/index.php?request=$1 [L,QSA]
#生产
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_URI}!= /的favicon.ico
的RewriteCond%{REQUEST_HOST} ^ www.mydomain.com
重写规则^(。*)$ /index.php?request=$1 [L,QSA]
I'm working on a app that uses url rewrites and has a specific .htaccess configuration. When working on the app I have three eviorments:
Developent on my local machine (localhost) Staging (staging.mydomain.com) Production (www.mydomain.com)I am constantly pushing new upgrades to the staging and production environment and each time I overwrite the existing source code I have to go in an change the .htaccess file. Is there a way I can the .htaccess generic to the directory or have it automatically detect it's environment?
My current .htaccess file is below. I just un-comment the sections between the different environments but would love to stop doing that...
# Development
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /app/index.php?request=$1 [L,QSA]
# Staging
# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^(.*)$ /html/app/index.php?request=$1 [L,QSA]
# Production
# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]
Thanks in advance!
Chuck
解决方案# Development
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_HOST} ^localhost
RewriteRule ^(.*)$ /app/index.php?request=$1 [L,QSA]
# Staging
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_HOST} ^staging.mydomain.com
RewriteRule ^(.*)$ /html/app/index.php?request=$1 [L,QSA]
# Production
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_HOST} ^www.mydomain.com
RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]