Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

2 index frontend/backend

$
0
0

@Maelstrom wrote:

Hello,

I am not sure I will get my answer on this forum, I could not find one by searching (might have used the wrong keywords though) but I am sure some people might have run into the issue. This is my first Ember App so I did not get the chance to run into production yet.

I have 2 index on my site:

  • index.html: for my Ember frontend
  • index.php: for my api/backend entrypoint

I am using an Apache server and hence, using an .htaccess for the config.

It looks like this (describing below the important parts):

SetEnv PHP_VER 5_6
SetEnv REGISTER_GLOBALS 0
SetEnv SESSION_USE_TRANS_SID 0

Options +ExecCGI -Indexes +FollowSymlinks
DirectoryIndex index.html index.php
DefaultLanguage fr-FR
AddDefaultCharset UTF-8
ServerSignature Off
RewriteEngine On

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico)$">
   Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(js|css|pdf|swf)$">
   Header set Cache-Control "max-age=0"
</FilesMatch>
<FilesMatch "\.(html|htm|txt)$">
   Header set Cache-Control "max-age=600"
</FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi|swf)$">
   Header unset Cache-Control
</FilesMatch>

#This is for Ember to work when using a URL other than root
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

RewriteCond %{HTTP_HOST} ^my-site\.com$ [NC]
RewriteRule ^(.*)$ http://www.my-site.com/$1 [R=301,L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.my-site.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://dev.my-site.com/.*$ [NC]
ReWriteRule .*\.(gif|png|jpe?g)$ - [F]

#Folder access denying
RedirectMatch 404 /(config|lib|inc|cron|upload)

#Those are the rules to redirect to my API
ReWriteRule ^api/(\w*)/(\w*)/?((?:\w|\d|-)*)?/?$ index.php?controller=$1&action=$2&id=$3 [L]
ReWriteRule ^api/(\w*)/?((?:\w|\d|-)*)?/?$ index.php?controller=$1&id=$2 [L]

I have 2 sets of rules that are interesting the < IfModule mod_rewrite.c> that makes my-site.com/pagename URLs work.

And the last 2 lines that are for the API.

Hence, I was expecting URLs such as my-site.com/api/whatever to use the index.php, it does not... the code returns the index.html

My code works well in dev because I proxy the APIs request with ember serve and they are located in different folds but, there it does not work.

In my server I have below structure:

  • /assets (Ember)
  • /config (api)
  • /inc (api)
  • /lib (api)
  • .htaccess
  • index.html (Ember)
  • index.php (api)

I am trying different things but, so far, could not make it work.

Would you guys have any suggestion?

ED: I'll try to move Ember's .html content in the PHP one and see how it goes. ED2: I'll try further tomorrow but, from first look, I don't seem to be able to make it work, Ember does not execute and just renders

{{content-for 'head'}} {{content-for 'head-footer'}} {{content-for 'body'}} {{content-for 'body-footer'}}

Cheers

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles