我有一个问题,让我解释一下。
WAMP上启用了Rewrite_module
我的主机已映射:
127.0.0.1 localhost
127.0.0.1 mydomain.com
我的虚拟主机在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 /
我有一个htaccess:
<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/
我认为RewriteBase不起作用,我不知道为什么。
非常感谢,对不起我的英语。
答案 0 :(得分:0)
我认为你误解了虚拟主机的观点。
您应该为每个项目创建一个虚拟主机,如下所示
<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
,除非这个项目实际需要它。