2017-05-11 7 views
-1

私は、新しいAngular 2/4アプリで古いzendウェブサイトをマージする際に問題があります。私はzendの別のURLとして私の角のアプリケーションを挿入したいと思います。Apache 2、Zend Angular 2 Appにリダイレクト

ドメインhttp://example.netは私のZend Webサイトにリダイレクトされます。 http://example.net/Angularは私のAngularアプリにリダイレクトされます。

私は別のファイルを作成し、すべてのコンパイル済みファイルをangular2からコピーしました。 http://example.net/Angularに行くとすごくうまくいっていますが、リンクを使ってウェブサイトを移動することができますが、http://example.net/Angular/profile/12のような入れ子になったリンクをリフレッシュしたり送信したりすると、404ページのzendにリダイレクトされます。

角度アプリの.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.html$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.html [L] 
</IfModule> 

このアプリではZendの.htaccess

Options +FollowSymLinks +ExecCGI 


php_value upload_max_filesize 24M 
php_value post_max_size 24M 
php_value memory_limit 512M 

RewriteCond %{HTTPS} !=on 
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] 
#https:// -> https://www. 
php_value safe_mode "0" 

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteBase/

    RewriteCond %{HTTP_USER_AGENT} msnbot [NC] 
    RewriteRule . - [F] 

    RewriteCond %{HTTP_HOST} ^example.net [NC] 
    #^ -> https://www. 
    RewriteRule ^(.*)$ https://www.example.net%{REQUEST_URI} [R=301,L] 
    #http -> https 
    # newsletter stats collector 
    RewriteCond %{REQUEST_URI} ^/ns/[0-9]+/[^/]+$ 
    RewriteRule ^(.*)$ _newsletter_stats.php [L] 

RewriteRule ^action/order.php order.php [L] 

    # newsletter tracker 
    RewriteCond %{REQUEST_URI} ^/nt/[0-9]+$ 
    RewriteRule ^(.*)$ _newsletter_tracker.php [L] 

    ErrorDocument 404 /404.html 


    RewriteCond %{REQUEST_URI} \..+$ 
    RewriteCond %{REQUEST_URI} !\.html$ 
    RewriteCond %{REQUEST_URI} !\.pdf$ 
    RewriteRule .* - [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 


    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 


<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/plain 
    AddOutputFilterByType DEFLATE text/html 
    AddOutputFilterByType DEFLATE text/javascript application/x-javascript 
</IfModule> 

<IfModule mod_gzip.c> 
    mod_gzip_on  Yes 
    mod_gzip_dechunk Yes 
    mod_gzip_item_include file  \.(html?|txt|js|php|pl|jpg|png|gif|css)$ 
    mod_gzip_item_include handler ^cgi-script$ 
    mod_gzip_item_include mime  ^text/.* 
    mod_gzip_item_include mime  ^application/x-javascript.* 
    mod_gzip_item_exclude mime  ^image/.* 
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
</IfModule> 

<IfModule mod_setenvif.c> 
# Netscape 4.x has some problems� 
BrowserMatch ^Mozilla/4 gzip-only-text/html 

# Netscape 4.06-4.08 have some more problems 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 

# MSIE masquerades as Netscape, but it is fine 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 
# the above regex won�t work. You can use the following 
# workaround to get the desired effect: 
#BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 

# Don�t compress already-compressed files 
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary 
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary 
SetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-vary 
SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary 
</IfModule> 

<FilesMatch ".(ico|jpg|jpeg|png|gif|js|swf|css)$"> 
    <IfModule mod_expires.c> 
    ExpiresActive on 
    ExpiresDefault A604800 
    Header append Cache-Control "public" 
    </IfModule> 
    Header unset ETag 
    FileETag None 
</FilesMatch> 

ルーティングシステムは、このサイトをコーディングされた人々に、おそらく不明であるので、私は固執したいと思いますhtaccessとAngularソリューション

また、私は既にノードサーバーや他のApache 2を実行することはできません...ホスティング。

答えて

1

角度アプリにはAliasを使用することをお勧めします(デプロイメントの観点でも、プロジェクトと成果物を分離しておくことを意味します)。あなたは、ファイルがディスク上に存在するかどうかを確認しDOCUMENT_ROOT /(あなたのZFアプリであることを)、照会として

あなたが設けられた第一.htaccessはおそらく/Angular/profile/12はないとindex.phpを果たすことがわかり、要求されていません。

他のソリューションは、したがって、ZF .htaccessに別の条件を追加することになる。

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteBase/

    #... 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(?!Angular/)(.+)$ /index.html/$1 [NC,QSA,L] 

    #... 
</IfModule mod_rewrite.c> 

そのような何か(試験せず)。


編集:何

# The following rule tells Apache that if the requested filename 
# exists, simply serve it. 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [L] 

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/Angular/(.*)::\2$ 
RewriteRule ^(.*) - [E=BASE:%1] 
RewriteRule ^(.*)$ %{ENV:BASE}/Angular/index.html [L] 

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
RewriteRule ^(.*) - [E=BASE:%1] 
RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L] 

そのことについていくつかの調整が必要な場合がありますここでも、そのようなエイリアスやウェブサイトごとにドメイン(app.domain.comとapi.domain.com)などの他のソリューション道のりは良いでしょう。

+0

正しいですが、最初の.htaccessは必須ではありませんが、指定したコードはすべてのネストされたURLで内部サーバーエラー500を引き起こします。 –

+0

Apacheエラーログにアクセスできますか?おそらくより良いリダイレクトで投稿を編集します –

関連する問題