Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][Symfony2]localhost/.../web/ wyświetla zawartość katalogu zamiast stronę
twojastara
post
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


Uczę się Symfony2 z książki Gajdy i od razu, robiąc krok po kroku jak autor pisze, efekty mam nie takie jak autor pokazuje. Nawet pomińmy moje krok po kroku. Wklejając autora pliki przykładowych gotowych projektów efekty są złe.

(wrzucam gotowy projekt do wamp/www/)

Autor po wykonaniu (każdego) przykładu każe obejrzeć projekt pod poniższymi adresami pisząc, że efekt jest taki sam dla każdego adresu:

Dla 1 projektu (wersja autora)
localhost/hello-world/web/app_dev.php/hello-world.html - OK
localhost/hello-world/web/app.php/hello-world.html - OK
localhost/hello-world/web/hello-world.html - 404 Not Found

Dla 2 projektu (wersja autora)
localhost/mountains/web/ - Index of /mountain/web
localhost/mountains/web/valley.html - 404 Not Found
localhost/mountains/web/app.php/valley.html - OK
------
edit: dodaje efekty na symfony 2.6
Dla 2 projektu (wersja moja)
localhost/mountains/web/- wyświetla mi jakiś domyślny napis Homepage. Nie to co trzeba.
localhost/mountains/web/valley.html - 404 Not Found
localhost/mountains/web/app.php/valley.html - An Error Occurred- 404 Not Found(innaczej wyglądający niż ten 404 wyżej)
-------
Gdzie mam szukać przyczyny?


(powoli zacznę wrzucać fragmenty kodu, które autor każe wstawiać robiąc projekt, ale może juz na tym etapie ktoś wie w czym rzecz)

Ten post edytował twojastara 11.12.2014, 15:32:36
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
twojastara
post
Post #2





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


W tym poście wklejam zawartość 4 plików .htaccess
Dwa autora robione na Symfony 2.0.10
Dwa moje robione w Symfony 2.6

-----------
edit (edytowałem tez pierwszy post)

/web/.htaccess gotowego projektu autora:
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. RewriteCond %{REQUEST_FILENAME} !-f
  4. RewriteRule ^(.*)$ app.php [QSA,L]
  5. </IfModule>


/web/.htaccess moje, nieruszane z Symfony 2.6
  1. # Use the front controller as index file. It serves as a fallback solution when
  2. # every other rewrite/redirect fails (e.g. in an aliased environment without
  3. # mod_rewrite). Additionally, this reduces the matching process for the
  4. # start page (path "/") because otherwise Apache will apply the rewriting rules
  5. # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
  6. DirectoryIndex app.php
  7.  
  8. <IfModule mod_rewrite.c>
  9. RewriteEngine On
  10.  
  11. # Determine the RewriteBase automatically and set it as environment variable.
  12. # If you are using Apache aliases to do mass virtual hosting or installed the
  13. # project in a subdirectory, the base path will be prepended to allow proper
  14. # resolution of the app.php file and to redirect to the correct URI. It will
  15. # work in environments without path prefix as well, providing a safe, one-size
  16. # fits all solution. But as you do not need it in this case, you can comment
  17. # the following 2 lines to eliminate the overhead.
  18. RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
  19. RewriteRule ^(.*) - [E=BASE:%1]
  20.  
  21. # Sets the HTTP_AUTHORIZATION header removed by apache
  22. RewriteCond %{HTTP:Authorization} .
  23. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  24.  
  25. # Redirect to URI without front controller to prevent duplicate content
  26. # (with and without `/app.php`). Only do this redirect on the initial
  27. # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
  28. # endless redirect loop (request -> rewrite to front controller ->
  29. # redirect -> request -> ...).
  30. # So in case you get a "too many redirects" error or you always get redirected
  31. # to the start page because your Apache does not expose the REDIRECT_STATUS
  32. # environment variable, you have 2 choices:
  33. # - disable this feature by commenting the following 2 lines or
  34. # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
  35. # following RewriteCond (best solution)
  36. RewriteCond %{ENV:REDIRECT_STATUS} ^$
  37. RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  38.  
  39. # If the requested filename exists, simply serve it.
  40. # We only want to let Apache serve files and not directories.
  41. RewriteCond %{REQUEST_FILENAME} -f
  42. RewriteRule .? - [L]
  43.  
  44. # Rewrite all other queries to the front controller.
  45. RewriteRule .? %{ENV:BASE}/app.php [L]
  46. </IfModule>
  47.  
  48. <IfModule !mod_rewrite.c>
  49. <IfModule mod_alias.c>
  50. # When mod_rewrite is not available, we instruct a temporary redirect of
  51. # the start page to the front controller explicitly so that the website
  52. # and the generated links can still be used.
  53. RedirectMatch 302 ^/$ /app.php/
  54. # RedirectTemp cannot be used instead
  55. </IfModule>
  56. </IfModule>


Projekt/source files/src/.htaccess w projekcie gotowym autora wygląda tak
  1. deny from all

Projekt/source files/src/.htaccess U mnie ten plik po komendzie generate:bundle wygląda tak:
  1. <IfModule mod_authz_core.c>
  2. Require all denied
  3. </IfModule>
  4. <IfModule !mod_authz_core.c>
  5. Order deny,allow
  6. Deny from all
  7. </IfModule>



a czy przypadkiem linia w /Apache/httpd.conf
  1. #LoadModule rewrite_module modules/mod_rewrite.so

nie powinna być bez komentarza?

Ten post edytował twojastara 11.12.2014, 17:30:12
Go to the top of the page
+Quote Post

Posty w temacie
- twojastara   [SF][Symfony2]localhost/.../web/ wyświetla zawartość katalogu zamiast stronę   11.12.2014, 14:36:49
- - ohm   Sprawdz czy masz plik .htaccess i mod_rewrite wlac...   11.12.2014, 14:42:03
- - phpion   Masz włączony mod_rewrite? W katalogu web obu apli...   11.12.2014, 14:42:42
- - twojastara   W tym poście wklejam zawartość 4 plików .htaccess ...   11.12.2014, 15:12:19
- - Forti   Powinna. Masz wyłączony mod_rewrite przez co htacc...   11.12.2014, 17:42:45
- - twojastara   Zgadza się. Projekty autora wyświetlają się teraz ...   12.12.2014, 09:34:16
- - Turson   Ksiązka opisuje wczesniejsza wersje niz 2.6 stad r...   12.12.2014, 09:38:13
- - twojastara   a jaki to będzie url? --------- edit jeśli loca...   12.12.2014, 11:13:48
- - Turson   Chyba tylko app_dev ma routing do demo bundle A na...   12.12.2014, 11:23:55
- - twojastara   no i co, jakieś wnioski w zwiazku z tym demo?   12.12.2014, 13:41:05
- - Turson   Masz routing do localhost/mountains/web/app.php/va...   12.12.2014, 13:45:46
- - twojastara   Po kolejnym przepisaniu przykładu wszystko jest ja...   12.12.2014, 16:32:23
- - ohm   A testujesz na trybie produkcyjnym czy developersk...   12.12.2014, 17:48:45
- - twojastara   app/cache? nie widzę takiego folderu   12.12.2014, 17:58:19
- - Turson   To ciekawe bo ja mam   12.12.2014, 20:17:53
- - Forti   W IDE często tego folderu nie ma. Sprawdź w eksplo...   13.12.2014, 08:06:55
- - twojastara   no tak, w eksploratorze pokazuje się. ----------...   13.12.2014, 16:33:32
- - Turson   app.php - tryb produkcyjny app_dev.php - developer...   13.12.2014, 16:39:19
- - twojastara   rozumiem. a jest jakiś powód bym nie zmieniał usta...   13.12.2014, 17:13:26
- - Turson   Dev powinien mieć wyłaczone cache właśnie z tego p...   13.12.2014, 17:31:14
- - twojastara   rozumiem, ja pytam o powód dla którego miałbym te ...   13.12.2014, 21:41:01
- - Turson   Po prostu ucz się na trybie deweloperskim. Jeżeli ...   13.12.2014, 21:43:16
- - twojastara   dzięki za odpowiedzi. Wrócę z poważniejszymi pytan...   13.12.2014, 21:58:31


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 01:41