Mod rewrite WAMP不工作时重写基础(vhost)
我有个问题,让我解释一下 WAMP上已启用“重写”模块 我的主机映射为:Mod rewrite WAMP不工作时重写基础(vhost),mod-rewrite,rewrite,wamp,Mod Rewrite,Rewrite,Wamp,我有个问题,让我解释一下 WAMP上已启用“重写”模块 我的主机映射为: 127.0.0.1 localhost 127.0.0.1 mydomain.com 我的vhost在WAMP上声明: <VirtualHost *: 80> ServerAdmin contact@mydomain.com DocumentRoot "E:/wamp/www/subfolder/" ServerName mydomain.com ErrorLog "logs/mydo
127.0.0.1 localhost
127.0.0.1 mydomain.com
我的vhost在WAMP上声明:
<VirtualHost *: 80>
ServerAdmin contact@mydomain.com
DocumentRoot "E:/wamp/www/subfolder/"
ServerName mydomain.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder /">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</ Directory>
</ VirtualHost>
现在,没问题,mydomain.com到达E:/wamp/www/subfolder/
我的项目位于子文件夹中,如E:/wamp/www/subfolder/My project/
我可以通过以下方式访问:
<Mod_rewrite.c IfModule>
RewriteEngine On
RewriteBase /my-project/
RewriteRule ^index\php$ - [L]
RewriteRule ^assets/css/(.*) /my-project/content/themes/assets/css/ $ 1 [QSA, L] [QSA, L]
RewriteCond% {REQUEST_FILENAME}! F
RewriteCond% {REQUEST_FILENAME}! -d
RewriteRule. /my-project/index.php [L]
</ IfModule>
我的问题来了。如果我访问mydomain.com/my-project/网站,它会毫无问题地访问该网站,但是css(例如)不会加载,因为链接是:
mydomain.com/content/themes/assets/css/
它应该有:
mydomain.com/my-project/content/themes/assets/css/
我认为这个基础不起作用,我不知道为什么
非常感谢,我的英语很抱歉。我想你误解了虚拟主机的意义 您应该为每个项目创建一个虚拟主机
<VirtualHost *: 80>
ServerAdmin contact@mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project1"
ServerName mydomain1.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project1">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *: 80>
ServerAdmin contact@mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project2"
ServerName mydomain2.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project2">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
这使得每个项目在外观和反应上都像是一个单独的网站,拥有自己独特的Apache实例,并且使将项目移动到实时服务器更加可靠
您现在也不需要.htaccess,除非这个项目确实需要它。谢谢您的回复,但我的问题就在这里。我必须保持mydomain.com/my-project格式,因为我必须使用位于服务器共享dev上的外部数据库,该服务器具有tree-mydomain.com/my-project。再次感谢你。