0

サブディレクトリの下にyiiウェブサイトがあります。

http://localhost/~username/maindirectory/yiiapp/

私のhtaccessファイル:

DirectoryIndex index.php index.html index.htm
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /yiiapp

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>

保護された/config/main.php

...
'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
....

問題:

私がアクセスするとしましょう:

  • 第一歩:http://localhost/~username/maindirectory/yiiapp/
  • ステップ 2: ホームページ (デフォルトの yii アプリ) の任意のリンクをクリックしAbout Usます。
  • ステップ 3:http://localhost/~username/maindirectory/yiiapp/site/page?view=about
  • ステップ4:リンクのいずれかをクリックします(同じページとしましょう)
  • URL は次のようになります。http://localhost/yiiapp/site/page?view=about

したがって、すべてのリンクは : としてアクセスできます。リンク http://localhost/yiiapp/.... から index.php を削除する代わりに、文字列 b/wlocalhostとベース ディレクトリが削除されます。

私はすでにこれを試しましたが、明らかにサブドメインを使用せずに、 localhost に同じ種類の URL が必要です

これを修正するのを手伝ってください。

4

3 に答える 3

0

部分的な答え:

問題は、同じドメインの絶対URLにリダイレクトしていることです。
URLはおそらくのようになり/yiiapp/site/page?view=aboutます。ただし、それはにつながりhttp://localhost/yiiapp/site/page?view=aboutます。ドメインを基準にしてWebサイトディレクトリを付加する必要があります(正しく表現したかどうかはわかりません)。

たとえば、a hrefタグ内のURLは次のようになります。そのため、どこかからパーツを/~username/maindirectory/yiiapp/site/page?view=about付加する必要があります。/~username/maindirectory

于 2012-11-23T11:29:25.310 に答える
0

/~username/maindir/yiiappそのため、.htaccess の RewriteBase'baseUrl' => '/~username/maindirectory/yiiapp'で config/main.phpの問題ではなく、問題が修正されました

完全な .htaccess ファイルは次のとおりです。

DirectoryIndex index.php index.html index.htm
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~username/maindir/yiiapp

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
于 2012-12-12T06:30:38.900 に答える
0

試してみてください:

'urlManager'=>array(
    ....
    'baseUrl' => '/~username/maindirectory/yiiapp',
    ....

http://www.yiiframework.com/doc/api/1.1/CUrlManager#setBaseUrl-detail

于 2012-11-24T09:52:27.970 に答える