OfficeStack / OpenSkedge

A flexible employee scheduling application built upon Symfony2 and Doctrine. Designed for companies and organizations with fluid shifts.
126 stars 38 forks source link

Routing Errors? #85

Open markjwill opened 10 years ago

markjwill commented 10 years ago

Just Installed openSkedge, excited to be a part of a fellow Minnesotan's project!

Just after install both https://openskedge/settings/ip-manifest/ https://openskedge/settings

were 404'ing so I looked in /src/OpenSkedge/AppBundle/Resources/config/routing.yml found lines 360-383

app_settings_ips:
    pattern:  /app/settings/ip-manifest/
    defaults: { _controller: OpenSkedgeBundle:IP:index }

app_settings_ip_new:
    pattern:  /app/settings/ip/new
    defaults: { _controller: OpenSkedgeBundle:IP:new }

app_settings_ip_edit:
    pattern:  /app/settings/ip/{id}/edit
    defaults: { _controller: OpenSkedgeBundle:IP:edit }
    requirements:
        id: \d+

app_settings_ip_delete:
    pattern:  /app/settings/ip/{id}/delete
    defaults: { _controller: OpenSkedgeBundle:IP:delete }
    methods: [POST]
    requirements:
        id: \d+

app_settings_edit:
    pattern:  /app/settings
    defaults: { _controller: OpenSkedgeBundle:Settings:edit }

Tried removing the /app bit since the urls do not have it

app_settings_ips:
    pattern:  /settings/ip-manifest/
    defaults: { _controller: OpenSkedgeBundle:IP:index }

app_settings_ip_new:
    pattern:  /settings/ip/new
    defaults: { _controller: OpenSkedgeBundle:IP:new }

app_settings_ip_edit:
    pattern:  /settings/ip/{id}/edit
    defaults: { _controller: OpenSkedgeBundle:IP:edit }
    requirements:
        id: \d+

app_settings_ip_delete:
    pattern:  /settings/ip/{id}/delete
    defaults: { _controller: OpenSkedgeBundle:IP:delete }
    methods: [POST]
    requirements:
        id: \d+

app_settings_edit:
    pattern:  /settings
    defaults: { _controller: OpenSkedgeBundle:Settings:edit }

And now everything seems to work! If I really knew what I was doing on gitHub I'd make a pull request, but Im still learning...

maxfierke commented 10 years ago

Hi Mark,

The URL pattern prefix for the app settings routes is intended to be /app/settings. Where were you getting /settings URLs?

markjwill commented 10 years ago

ok, I was really confused for a while, and then I thought I solved it, but now Im still confused...

Right after install if I clicked on "IP manifest" I got https://openskedge/settings/ip-manifest/ 404'd... After looking at the routing, I tried typing it in with the "app" in there, and my browser just rerouted me to the same https://openskedge/settings/ip-manifest/ 404... I should have caught that something was amiss right there, but instead I tried removing /app in the routing and everything seemed to work. I have now set things back to the way it was installed to check the links and they did indeed target /app/settings...

I now think that my virtual host is doing some kind of redirect that is filtering "app" out of the urls... if I change the routes to "/ape" then they also work and appear as expected. I tried editing my virtual host a few different ways, but I don't seem to be able to change it away from redirecting out the /app. If I'm in the app_dev.php, then all the urls also work as expected: https://openskedge/app_dev.php/app/settings/ip-manifest/ ...

So in conclusion, I think it's my virtual host? but I can't figure out how or why... I do have another symfony2 project ( Sylius ) that I've been using my server for, so I may have setup something specific for pretty urls with that?

Does my change break anything? or do you think it would be fine to leave it in?

My setup is Ubuntu 12.04 on virtualBox

$ php -v
PHP 5.3.10-1ubuntu3.11 with Suhosin-Patch (cli) (built: Apr  4 2014 01:27:23) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
$ apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built:   Mar 19 2014 21:10:40
maxfierke commented 10 years ago

It does sound like an issue specific to your Apache configuration. I can take a look at it if you want. Either post it here, or shoot me an email (listed on my GitHub profile).

markjwill commented 10 years ago
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/openSkedge/OpenSkedge/web
        ServerName openskedge:443

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key

        <Directory />
                Options FollowSymLinks
                AllowOverride all
        </Directory>
        <Directory /var/www/openSkedge/OpenSkedge/web/>
                Options FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
        </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>
</IfModule>

This is part of my /etc/apache2/sites-enabled/000-default file that I setup for openSkedge... I know ubuntu has a bunch of separate conf files that are included in apache's settings, but I don't know where else something might be that would affect this site...

maxfierke commented 10 years ago

Try removing the rewrite rules from that <Directory /var/www/openSkedge/OpenSkedge/web/> block. The web directory has an .htaccess that will route everything to app.php. The rewrite rules in your vhost are likely conflicting with those defined in the .htaccess.

markjwill commented 10 years ago

Shoot, forgot to mention that I did already try commenting out the 3 rewrite rule lines.

markjwill commented 10 years ago

I searched through all my known apache2 config files, couldn't find any changes that would stop the redirect away from /app. I then looked in the .htaccess file and found this section

    # Redirect to URI without front controller to prevent duplicate content
    # (with and without `/app.php`). Only do this redirect on the initial
    # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    # endless redirect loop (request -> rewrite to front controller ->
    # redirect -> request -> ...).
    # So in case you get a "too many redirects" error or you always get redirected
    # to the startpage because your Apache does not expose the REDIRECT_STATUS
    # environment variable, you have 2 choices:
    # - disable this feature by commenting the following 2 lines or
    # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    #   following RewriteCond (best solution)
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]

Commenting out the last line stops the redirect away from the /app urls. it also now allows app.php ( https://openskedge/app.php/dashboard/ ) ... but doesn't seem to default to include the app.php, so this seems a fine solution for my case.

maxfierke commented 10 years ago

I'll do some experimenting with Apache when I get a chance to see if I can reproduce this to categorize it as an Apache issue that needs to be fixed, or whether it's an issue specific to your environment.