2014-01-07 71 views
0

你好幾個月前,我開始了一個網站項目,昨天晚上幾個星期後,我繼續在我的Windows PC上開發它,一切正常。 今天我把它移植到Ubuntu 12.04 LTS和啓動我的Apache/MySQL後,試圖打一些網站網址(設置了像這樣的虛擬主機:tms.localhost /路徑...)。htaccess不能在ubuntu工作

的問題我面對,我不知道爲什麼是乾淨的網址和mod_rewrite似乎沒有工作。我的自定義php重定向 - 頁面加載腳本不再被調用(index.php)。

以下是自第1天起未更改的htaccess。需要提及的是,只有在我輸入虛擬主機url之類的情況下才有效,如果我在添加任何東西之後添加了任何內容,那麼我將獲得默認的apache 404頁面。

#Debugging - Error reporting 
php_flag display_startup_errors on 
php_flag display_errors on 
php_flag html_errors on 

#Commpression 
<ifmodule mod_deflate.c=""> 
    <filesmatch ".(js|css|html|png|jpg|jpeg|swf|bmp|gif|tiff|ico|eot|svg|ttf|woff|pdf)$"=""> 
     SetOutputFilter DEFLATE 
    </filesmatch> 
</ifmodule> 

Options All -Indexes +FollowSymLinks -MultiViews 

<IfModule mod_rewrite.c> 

    # Turn mod_rewrite on 
    RewriteEngine On 
    RewriteBase/

    # remove spaces from start or after/
    #RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L,R=301,NE] 
    # remove spaces from end or before/
    #RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L,R=301,NE] 


    # replace spaces by - in between 
    #RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1+$2 [L,R=301,NE] 


    # Remove trailing slash 
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [L,R=301] 

    # Add trailing slash 
    #RewriteCond %{REQUEST_URI} !(/$|\.) 
    #RewriteRule (.*) %{REQUEST_URI}/ [L,R=301] 

    # Remove multiple slashes 
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/{2,} [NC] 
    RewriteRule ^(.*) $1 [R=301,L] 

    # Clean url rewrite 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_URI} !^.*\.(png|jpg|jpeg|bmp|gif|css|js|json)$ [NC] 
    #RewriteRule ^([^/]+/?.+)$ /index.php?req=$1 [L,QSA] 
    #RewriteRule ^(.*)$ /index.php?req=$1 [L,QSA] 
    RewriteRule ^(.*)$ /index.php [L,QSA] 

</IfModule> 

# Big thnx to anubhava for his regex help - linkedin.com/in/anubhava 

UPDATE

在index.php工程作爲頁面文件加載它不包含任何HTML。 只有根網址工作並加載相應的php文件,因此啓用了mod_rewrite。 htaccess無法翻譯剩餘的請求我想?

vhostfile tms.localhost

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www/tms 
    ServerName tms.localhost 
    #ServerAlias www.example.com 

</VirtualHost> 

模塊的phpinfo():

core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status 
+0

是否已進行了確認mod_rewrite啓用? – vascowhite

+0

什麼phpinfo()函數說? – chanchal118

+0

這是什麼.htaccess文件的位置? – anubhava

回答

0

那麼有沒有什麼不妥的地方。 顯然,無論是壓縮程序或谷歌驅動器(我不停的項目更名.htaccesshtaccess ...