简体   繁体   English

Apache2中的别名时RewriteRule失败

[英]RewriteRule fails when Alias in Apache2

So, I wanted to organise my projects for better developing. 因此,我想组织我的项目以更好地进行开发。 I chose using this way to organise folders & files: 我选择使用这种方式来组织文件夹和文件:

www
    projects
        project1
           web
           design_tests
        project2
           web
           design_tests
...

The website of each project will go inside its "web" folder. 每个项目的网站都将位于其“ web”文件夹中。 I also wanted to access the web on the browser without putting the "web" folder name, so: 我还想在浏览器上访问Web而不放置“ web”文件夹名称,因此:

http://localhost/projects/project1
will access the physical files of:
/www/projects/project1/web

I accomplished that adding the next line to my /etc/apache2/sites-available/default file: 我完成了将下一行添加到我的/ etc / apache2 / sites-available / default文件中的操作:

AliasMatch ^/projects/([^/]*)(/.*)? /www/projects/$1/web$2

Works perfectly. 完美运作。 The problem is, in some websites, i have an .htaccess file with some RewriteRule rules. 问题是,在某些网站中,我有一个带有某些RewriteRule规则的.htaccess文件。 An example: 一个例子:

RewriteEngine On
RewriteRule styles\.css styles_20120107.css

They used to work without the alias and acessing normal. 他们以前没有别名并且正常工作。 Now they don't. 现在他们没有。 It redirects to the URL /project1/web/styles_20120107.css, and of course, the browser can't get it because of the Alias. 它重定向到URL /project1/web/styles_20120107.css,当然,由于别名,浏览器无法获取它。 I don't really know how to solve it. 我真的不知道该怎么解决。 Can you give me some help about it please? 您能帮我一下吗? If possible, doing modifications in the file /etc/apache2/sites-available/default, not on the .htaccess, because i want the websites to be cross-server. 如果可能的话,请在文件/ etc / apache2 / sites-available / default中进行修改,而不是对.htaccess进行修改,因为我希望这些网站可以跨服务器使用。

Thanks in advance :) 提前致谢 :)

如果添加[PT]标志对您不起作用...为什么不使用重写规则替换别名来实现相同目的-在这种情况下,您应该完全避免此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM