I jave a server with multiple directories on root :
When I visit the site, the URL is mysite.org/site or mysite.org/forum.
What I would like is too configure my .htaccess to behave like this :
I can't manage to have this working...
Currently my .htaccess is like this :
RewriteEngine On
# Map http://www.example.com to /site.
RewriteRule ^$ /site/ [L]
# Map http://www.example.com/x to /site/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^(.*)$ /site/$1
# Add trailing slash to directories without them so DirectoryIndex works.
# This does not expose the internal URL.
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/
# Disable auto-adding slashes to directories without them, since this happens
# after mod_rewrite and exposes the rewritten internal URL, e.g. turning
# http://www.example.com/about into http://www.example.com/site/about
DirectorySlash off
Could someone help me please ?
答案 0 :(得分:0)
我不确定.htaccess是否可行。无论如何,我认为最好/最好的方法是将子目录拆分为由同一个apache服务的不同网站。
例如:
将/var/www/mysite.org/wiki/*
移至 - > /var/www/wiki.mysite.org/*
将/var/www/mysite.org/forum/*
移至 - > /var/www/forum.mysite.org/*
保持/var/www/mysite.org there
然后构建apache配置,如:
<强> mysite.conf:强>
# domain: mysite.org
# public: /var/www/mysite.org
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin@mysite.org
ServerName mysite.org
ServerAlias www.mysite.org *.mysite.org mysite.org
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/mysite.org/
<Directory /var/www/mysite.org>
Options -Indexes
Options +FollowSymLinks
Options -Includes
Options -ExecCGI
AllowOverride All
Require all granted
</Directory>
# Log file locations
LogLevel warn
ErrorLog /var/log/apache2/mysite.org_error.log
CustomLog /var/log/apache2/mysite.org_access.log combined
</VirtualHost>
<强> wiki.conf:强>
# domain: wiki.mysite.org
# public: /var/www/wiki.mysite.org
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin@mysite.org
ServerName wiki.mysite.org
ServerAlias wiki.mysite.org
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/wiki.mysite.org/
<Directory /var/www/wiki.mysite.org>
Options -Indexes
Options -FollowSymLinks
Options -Includes
Options -ExecCGI
AllowOverride All
Require all granted
</Directory>
# Log file locations
LogLevel warn
ErrorLog /var/log/apache2/wiki.mysite.org_error.log
CustomLog /var/log/apache2/wiki.mysite.org_access.log combined
</VirtualHost>
通过这种方式,您可以在每个站点的基础上指定不同的设置(日志文件,配置包括等),并使用mpm_itk来运行具有不同UID / GID的每个站点。