2014-02-19 27 views
2

在Ubuntu 13.10上我使用的是Apache 2.4.x。我遇到mod_rewrite問題。我啓用了模塊和並重新啓動服務器,但某些搜索後.htaccess文件仍然不工作,所以我,我讀了計算器朝指向一個答案:http://smarttips.in/htaccess-redirect-not-working-apache/mod_rewrite不能正常工作,所以在修復它時得到403禁止

我失蹤了2點在上面的鏈接。所以我把這個代碼放在我的000-default.conf文件中。

DocumentRoot /var/www 
     <Directory /> 
    Options FollowSymLinks 
     AllowOverride All 
    </Directory> 
    <Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
    </Directory> 

由於我使用apache2.4 +這樣告訴這裏:http://httpd.apache.org/docs/current/upgrading.html

Order allow, deny 
Allow from all 

Require all granted 

這裏是我的000-default.conf文件代碼:

<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 
    <Directory /> 
     Options FollowSymLinks 
     AllowOverride All 
    </Directory> 
    <Directory /var/www/> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Require all granted 
    </Directory> 
    # 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> 

但是,從t帽子鏈接,現在服務器是給403禁止的,他說:

You don't have permission to access /mysite/ on this server. 
Apache/2.4.6 (Ubuntu) Server at localhost Port 80 

所以不知道這mod_rewrite的問題得到解決或沒有,但現在也越來越權限錯誤。 讓我知道是否需要在這裏放入.htaccess代碼。

因此,任何想法我做錯了什麼?

+0

你目前在那個目錄中有htaccess文件,你是否嘗試刪除任何規則以查看它是否在沒有它的情況下工作? –

+0

@PanamaJack yes在'var/www/mysite /'目錄中 – Hafiz

+0

@Hafiz:你有沒有可能啓用SELinux? – anubhava

回答

0

我只是刪除:

DocumentRoot /var/www 
    <Directory /> 
Options FollowSymLinks 
    AllowOverride All 
</Directory> 
<Directory /var/www/> 
Options Indexes FollowSymLinks MultiViews 
AllowOverride All 
Order allow,deny 
allow from all 
</Directory> 

,並把這個改爲:

DocumentRoot /var/www 
<Directory /var/www> 
AllowOverride All 
</Directory> 

而現在,權限錯誤消失了,mod_rewrite並工作正常。