2012-03-14 50 views
1

我試圖使用Apache的RewriteRules從網址中去除的index.php,但我撞到南牆的index.php形式的URL。重寫只使用httpd.conf中的EZ發佈網站

以下網址目前解決他們正確的網頁:

http://dev.morningstaronline.co.uk/index.php/content/view/full/215

http://dev.morningstaronline.co.uk/content/view/full/113635

但對於搜索引擎優化的原因,我需要自動和無形刪除URL的/index.php/一部分。廣泛的谷歌搜索和堆棧溢出搜索只會讓我走上盲目的小巷,要麼完全破壞網站,要麼離開我。

在httpd.conf樣本:

<VirtualHost 109.200.2.197:80> 

    <Directory /var/www/sites/ms_dev> 
     Options FollowSymLinks ExecCGI 
     AllowOverride All 
    Options +Indexes 
    </Directory> 

    <FilesMatch "\.(js|css|html|pdf|jpg|gif)$"> 
    SetOutputFilter DEFLATE 
    </FilesMatch> 

    CustomLog /var/log/httpd/ms-dev combined 
    ErrorLog /var/log/httpd/errors-ms-dev 

    AcceptPathInfo On 

    php_value date.timezone Europe/London 
    php_value magic_quotes_gpc 0 
    php_value magic_quotes_runtime 0 


    RewriteEngine On 
    RewriteRule ^/awstats - [L] 
    RewriteRule ^/hold\.php - [L] 
    RewriteRule content/treemenu/? /index_treemenu.php [L] 
    RewriteRule ^/images/.* - [L] 
    RewriteRule ^/var/storage/.* - [L] 
    RewriteRule ^/var/[^/]+/storage/.* - [L] 
    RewriteRule ^/var/cache/texttoimage/.* - [L] 
    RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L] 
    RewriteRule ^/var/[^/]+/cache/public/.* - [L] 
    RewriteRule ^/var/cache/public/javascript/.* - [L] 
    RewriteRule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L] 
    RewriteRule ^/share/icons/.* - [L] 
    RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|lib|flash|javascripts?)/.* - [L] 
    RewriteRule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L] 
    RewriteRule ^/packages/styles/.+/thumbnail/.* - [L] 
    RewriteRule ^/favicon\.ico - [L] 
    RewriteRule ^/robots\.txt - [L] 
    RewriteRule ^/crossdomain\.xml - [L] 

    RewriteRule !\.(gif|jpe?g|png|css|s|ico|js|jar|html)|var(.+)storage.pdf(.+)\.pdf$ /index.php 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/sites/ms_dev 
    ServerName ms_dev 
    ServerAlias dev.morningstaronline.co.uk 
    ServerAlias test.morningstaronline.co.uk 
    DirectoryIndex index.php 

</VirtualHost> 

這是基於一個古老的httpd.conf中,我從我們的現場服務器,也與完整的index.php(不需要)提供URL繼承。

任何幫助將不勝感激。

回答

0

看來,在推薦的RewriteRules最後一行丟失:

RewriteRule .* /index.php 

編號:http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Installation/Virtual-host-setup/Virtual-host-example

+0

感謝您既爲您快速回復,但使用這兩種解決方案時,問題仍然存在,或者兩者都存在。 輸入http://dev.morningstaronline.co.uk/index.php/content/view/full/113713 或 http://dev.morningstaronline.co.uk/content/view/full/113713 都帶來了正確的頁面,但仍然index.php的(前)。 難道還有一個配置選項潛伏在我的服務器上的其他地方,我不知道? 再次感謝 – user1269362 2012-03-19 16:04:02

+0

你試過迫使「ForceVirtualHost」配置指令爲true,eZ Publish的?你可以在這裏找到更多的細節:https://github.com/ezsystems/ezpublish/blob/master/settings/site.ini#L659 – Nicolas 2012-03-21 18:55:12

0

使用此代碼在您的.htaccess:

# to make any index.php/foo to /foo in browser (external redirect) 
RewriteRule ^index\.php/(.+)$ $1 [L,NC,R] 

# to forward any /foo to /index.php/foo (internal redirect) 
RewriteRule ^((?!index\.php).*)$ index.php/$1 [L,NC]