2014-04-18 199 views
1

我在/srv/http/site-dir/我的網站,並在其根.htaccess有以下幾點:vhosts.conf重寫規則

Options -MultiViews 

RewriteEngine On 

Options -Indexes 

RewriteBase /site-dir/ 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-l 

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

它的工作原理是這樣的,但現在我想這些規則移動到的httpd-vhosts.conf文件,所以我需要改變它以便從那裏開始工作,從而避免使用.htaccess,如果您可以訪問主.conf文件,那麼我讀的是練習牀?

編輯: 進入我的httpd-vhosts.conf嘗試建議,但沒有成功。

<VirtualHost *:80> 
    DocumentRoot "/srv/http/site-dir" 
    ServerName project-site-dir.my 
    ServerAlias www.project-site-dir.my 

    Options -MultiViews -Indexes 

    RewriteEngine On 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-l 
    RewriteRule ^/site-dir/(.+)$ /site-dir/index.php?url=$1 [QSA,L] 

    ErrorLog "/var/log/httpd/project-site-dir.my-error_log" 
    CustomLog "/var/log/httpd/project-site-dir.my-access_log" common 
</VirtualHost> 

回答

1

你可以把這個片段在httpd-vhosts.conf文件:

<VirtualHost *:80> 
    DocumentRoot "/srv/http/site-dir" 
    ServerName project-site-dir.my 
    ServerAlias www.project-site-dir.my 

    Options -MultiViews -Indexes 

    RewriteEngine On 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-l 
    RewriteRule ^/(.+)$ /index.php?url=$1 [QSA,L] 

    ErrorLog "/var/log/httpd/project-site-dir.my-error_log" 
    CustomLog "/var/log/httpd/project-site-dir.my-access_log" common 
</VirtualHost> 
+0

請看到我的編輯 – branquito

+0

你用什麼URL來測試它? – anubhava

+0

查看更新的答案。 – anubhava