2013-08-29 76 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無或所有任何建議? –