Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP+Symfony] adres url bez web
dopelganger
post
Post #1





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


cześć
jak w .htaccess ukryć / usunąć z adresu "web", mam coś takiego:

http://subdomena.domena.pl/web/kontakt
http://subdomena.domena.pl/web/news
itd...

.htaccess:

  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. Allow from all
  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}/$1 [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.  
  47. </IfModule>
  48.  
  49. <IfModule !mod_rewrite.c>
  50. <IfModule mod_alias.c>
  51. # When mod_rewrite is not available, we instruct a temporary redirect of
  52. # the start page to the front controller explicitly so that the website
  53. # and the generated links can still be used.
  54. RedirectMatch 302 ^/$ /app.php/
  55. # RedirectTemp cannot be used instead
  56. </IfModule>
  57. </IfModule>
  58.  

Go to the top of the page
+Quote Post
Forti
post
Post #2





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


To jest na serwerze tak?

Masz folder public_html (nie pamietam dokladnie nazwy). Całą aplikacje powinieneś umieścić w folderze, w którum znajduje się ów public_html, a nie konkretnie w nim. np:

domain
- public_html
- logs czy tam inne foldery.

Ty wrzuciłeś symfony do public_html, a powinieneś do domain. Rozumiesz? Następnie folder public_html usuwasz, a folder web (tak, ten właśnie tworzony przez symfony) zmieniasz nazwę na public_html.


Łopatologicznie, nie wiem jak inaczej ;]

Ten post edytował Forti 29.12.2014, 10:34:45
Go to the top of the page
+Quote Post
Turson
post
Post #3





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Ja bym to załatwił virtualhostem, jako documentroot dla domeny ustawiasz sciezke do symfony web/
Go to the top of the page
+Quote Post
dopelganger
post
Post #4





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


Cytat(Turson @ 29.12.2014, 10:40:02 ) *
Ja bym to załatwił virtualhostem, jako documentroot dla domeny ustawiasz sciezke do symfony web/


a w htaccess można to zrobić? bo do ustawień i plików serwera nie mam dostępu
Go to the top of the page
+Quote Post
Forti
post
Post #5





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


Można... Przed /app dodaj po prostu /web

Ten post edytował Forti 29.12.2014, 11:08:15
Go to the top of the page
+Quote Post
dopelganger
post
Post #6





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


Cytat(Forti @ 29.12.2014, 11:08:02 ) *
Można... Przed /app dodaj po prostu /web


wszędzie?

jesli tak to nie działa
Go to the top of the page
+Quote Post
Forti
post
Post #7





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


To zrób tak jak Ci napisałem prędzej. To nie jest żadna zła praktyka czy coś w tym stylu.

btw, virtual hosty prawdopodobnie możesz określić w panelu użytkownika / administratora twojego hostingu. Tam gdzie tworzysz bazy danych itp. Przynajmniej ja na hostingu za 9zł mogę tą lokalizacje zmienić (czytaj do public_html dodać np. /web/).
Go to the top of the page
+Quote Post
SpiritCode
post
Post #8





Grupa: Zarejestrowani
Postów: 167
Pomógł: 35
Dołączył: 29.12.2014
Skąd: Otwock

Ostrzeżenie: (0%)
-----


Cytat(Forti @ 29.12.2014, 12:05:16 ) *
To zrób tak jak Ci napisałem prędzej. To nie jest żadna zła praktyka czy coś w tym stylu.

btw, virtual hosty prawdopodobnie możesz określić w panelu użytkownika / administratora twojego hostingu. Tam gdzie tworzysz bazy danych itp. Przynajmniej ja na hostingu za 9zł mogę tą lokalizacje zmienić (czytaj do public_html dodać np. /web/).


Przy płatnych powinna być taka możliwość. Niestety większość darmowych hostingów ma takie opcje poblokowane a w panelu nie wiele można zmienić
Go to the top of the page
+Quote Post
Forti
post
Post #9





Grupa: Zarejestrowani
Postów: 655
Pomógł: 73
Dołączył: 2.05.2014

Ostrzeżenie: (0%)
-----


Jak ma darmowy hosting to nie powinien narzekać tylko kopiować całość wg. opisu z mojego pierwszego postu. Proste.
Go to the top of the page
+Quote Post
dopelganger
post
Post #10





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


virtualhost załatwił sprawe (IMG:style_emoticons/default/smile.gif)


dzięki za pomoc
zamykamy
Go to the top of the page
+Quote Post

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: 4.10.2025 - 13:16