1

私のウェブサイトのコピーが localhost にあります:

/var/www/vhosts/mysite.com/httpdocs

これは私の /etc/apache2/sites-available/mysite です

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/vhosts/mysite.com/httpdocs
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

htaccess.txt を .htaccess にコピーしました。フレンドリ URL と URL 書き換えを有効にすると、404 エラーが発生します。

.htaccess でこの行のコメントを外しましたが、まだ機能しません:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

また、rewritebaseをに変更しようとしました

RewriteBase /mysite

運がない。

私が間違っていることは何ですか?

4

2 に答える 2

1

これが発生している問題であるかどうかはわかりませんが、「localhost」では書き換えがうまく機能しないことを経験しました。ホストファイルを変更して、

127.0.0.1     mysite.local

そして、そのURLでアクセスします。

それがうまくいくかどうかはわかりませんが、試してみる価値はあります。

于 2012-09-27T08:17:17.023 に答える
1

解決しました!/etc/apache2/sites-available のさまざまなエントリと競合しました。localhost で新しいサイトを作成するときは、 にコピーdefaultし、 DocumentRoot を指すようにファイルをmysite変更します。mysite正確な理由はわかりませんが、デフォルト サイトを無効にすると:

sudo a2dissite default

できます。

これで問題が解決しない可能性がありますが、この問題に特化した別の質問を発行することをお勧めします。これは、テストしたところ、有効になっているさまざまなサイトと RewriteEngine が有効になっている 1 つ以上のサイトに関連しているためです。

于 2012-09-27T18:39:57.193 に答える