2013-08-29 79 views
0

我一直在寻找通过stackoverflow网站,我无法找到我的问题的答案。Ubuntu htaccess问题

当安装apache2时,它已经保留了默认值,并且webroot是/ var/www /但是如果我创建了一个名为/ var/www/test /的新webspace,如果我输入.htaccess文件,它不起作用。我试图添加到default.conf文件,然后重新加载文件,但它仍然不起作用。任何人都可以提供建议吗?

我的Apache的配置文件是如下:

<VirtualHost *:80> 
    # The ServerName directive sets the request scheme, hostname and port that 
    # the server uses to identify itself. This is used when creating 
    # redirection URLs. In the context of virtual hosts, the ServerName 
    # specifies what hostname must appear in the request's Host: header to 
    # match this virtual host. For the default virtual host (this file) this 
    # value is not decisive as it is used as a last resort host regardless. 
    # However, you must set it for any further virtual host explicitly. 
    #ServerName www.example.com 

    ServerAdmin [email protected] 
    DocumentRoot /var/www 

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
    # error, crit, alert, emerg. 
    # It is also possible to configure the loglevel for particular 
    # modules, e.g. 
    #LogLevel info ssl:warn 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    # For most configuration files from conf-available/, which are 
    # enabled or disabled at a global level, it is possible to 
    # include a line for only one particular virtual host. For example the 
    # following line enables the CGI configuration for this host only 
    # after it has been globally disabled with "a2disconf". 
    #Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

谁能提供任何意见?

回答

0

你有没有在你的Apache配置文件中的这条线(默认为/etc/apache2/sites-available/default)?

AllowOverride None 

如果是这样,将其更改为包括你在.htaccess文件需要的功能(见AllowOverride documentation)。

AllowOverride AuthConfig FileInfo ... 

也有可能是您的.htaccess文件的问题。例如,您有:

<IfModule mod_rewrite.c> 

mod_rewrite实际启用?如果没有,你需要这样做。

你说你也试过:

Redirect /index.html mynewwebsite.com/foldername 

这只会做任何事情,如果你真的去/index.html在浏览器中。

+0

这就是我不明白上面的文件是整个我的htaccess文件没有关于AllowOverride没有存在或个人网站 –

+0

你的'.htaccess'文件不应该看起来像你上面发布的东西。你发布的内容看起来像一个Apache服务器配置文件,它位于'/ etc/apache2/sites-enabled'中,并链接到'/ etc/apache2/sites-available'来启用该特定网站。然而,'.htaccess'文件位于网站的*个人文件夹*中,并指定与*该文件夹* - * not *'VirtualHost'或记录指令相关的选项。 – jnylen

+0

对不起,这就是我的意思。道歉我的意思是说我的apache conf文件(正如我上面发布的)似乎没有任何AllowOverride无或所有任何建议? –