Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Konfiguracja .htaccess
trifek
post 8.10.2018, 13:13:08
Post #1





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 28.09.2015

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


Cześć.
Mam takiego .htaccessa:

  1. Options +FollowSymLinks
  2. RewriteEngine on
  3. RewriteRule cache/ - [F]
  4. Options -Indexes
  5.  
  6. RewriteCond %{REQUEST_FILENAME} !-f
  7. RewriteCond %{REQUEST_FILENAME} !-d
  8. RewriteCond %{REQUEST_FILENAME} !-l
  9. RewriteRule ^([a-zA-Z0-9\-\_\/]*)$ index.php?p=$1
  10.  
  11. # Blokada hotlinking czyli kradzieży obrazków
  12. RewriteCond %{HTTP_REFERER} !^https://(.+\.)?nazwadomeny.pl/ [NC]
  13. RewriteCond %{HTTP_REFERER} !^$
  14. RewriteCond %{HTTP_REFERER} !google\. [NC]
  15. RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
  16. # Prevent viewing of htaccess file.
  17. <Files .htaccess>
  18. order allow,deny
  19. deny from all
  20. </Files>
  21. RedirectMatch 403 ^.*/apps/(.*).php(.*)$
  22.  
  23. <ifModule mod_gzip.c>
  24. mod_gzip_on Yes
  25. mod_gzip_dechunk Yes
  26. mod_gzip_item_include file .(html?|txt|css|js|php|pl|map)$
  27. mod_gzip_item_include handler ^cgi-script$
  28. mod_gzip_item_include mime ^text/.*
  29. mod_gzip_item_include mime ^application/x-javascript.*
  30. mod_gzip_item_exclude mime ^image/.*
  31. mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
  32. </ifModule>
  33. Linki w serwisie wyglądają tak:
  34. <a href="http://localhost/admin/SystemConfiguration/RemoveFile" target="_blank">http://localhost/admin/SystemConfiguration/RemoveFile</a>
  35. <a href="http://localhost/admin/SystemConfiguration/AddFile" target="_blank">http://localhost/admin/SystemConfiguration/AddFile</a>
  36. <a href="http://localhost/admin/SystemConfiguration" target="_blank">http://localhost/admin/SystemConfiguration</a>




Chciałbym żeby dodatkowo rozszerzyć to o możliwość dodania kolejnego ukośnika z parametrem:

  1. <a href="http://localhost/admin/UserList/User/IDUsera" target="_blank">http://localhost/admin/UserList/User/IDUsera</a>
  2. <a href="http://localhost/admin/UserList/User/IDUsera/Category" target="_blank">http://localhost/admin/UserList/User/IDUsera/Category</a>
  3.  




Lub jeśli się nie da, to chociaż żeby skrypt zaczął "łapać" wartości z $_GET:
  1. localhost/admin/UserList/User?id=IDUsera



Chociaż wolałbym to 1 rozwiązanie.

Dispatcher mojej aplikacji wygląda w sposób następujący:

  1. class Dispatcher
  2. {
  3. private $request;
  4.  
  5. public function dispatch()
  6. {
  7. $this->request = new Request();
  8. Router::parse($this->request->url, $this->request);
  9. $controller = $this->loadController();
  10. call_user_func_array([$controller, $this->request->action], $this->request->params);
  11. }
  12.  
  13. public function loadController()
  14. {
  15. $config = \Core\Utilities\Registry::register("Core\Utilities\Config");
  16. if (ADMIN_MODE === true) {
  17. $file = $config->backend_controller_path . '' . $this->request->controller . '.php';
  18. $controllerName = 'Backend\Controllers\\' . $this->request->controller . "AdminController";
  19. } else {
  20. $file = $config->frontend_controller_path . '' . $this->request->controller . '.php';
  21. $controllerName = 'Frontend\Controllers\\' . $this->request->controller . "Controller";
  22. }
  23.  
  24. if (file_exists("../" . $file)) {
  25. require_once("../" . $file);
  26. $controller = new $controllerName();
  27. return $controller;
  28. } else {
  29. header("HTTP/1.1 301 Moved Permanently");
  30. header("Location: " . SERVER_ADDRESS);
  31. exit();
  32. }
  33.  
  34. }
  35. }
  36.  
  37. class Request
  38. {
  39. public $url;
  40.  
  41. public function __construct()
  42. {
  43. $this->url = str_replace("p=", "", $_SERVER['QUERY_STRING']);
  44. }
  45. }
  46.  




Czy da się wprowadzić taką zmianę bez modyfikacji php (w samym .htaccesie)?
Może to być widoczne jako kolejny parametr czy coś....


Mam działającą aplikację, do której mam dorobić jakiś drobiazg - dlatego nie chce za bardzo zmieniać php, żeby nic się nie sypneło

Ten post edytował trifek 8.10.2018, 13:14:41
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 16:07