|
Regular expression i htaccess regex, PCRE, POSIX, upotreba Apache .htaccess , mod_rewrite |
|
Alati teme | Način prikaza |
![]() |
#8 |
Boris
Grand Master
Datum učlanjenja: 01.12.2005
Lokacija: Novi Sad
Poruke: 775
Hvala: 5
156 "Hvala" u 2 poruka
![]() ![]() |
![]() najbolje performanse se postizu ako se mod_rewrite pravila upisu direktno u vhost config. uostalom, neke rewrite opcije ni ne mogu da se promene iz per-directory (.htaccess) config fajlova (kao npr RewriteLog).
RewriteMap je dosta mocan alat. Jasno je meni zasto Ilija radi ovako - zgodnije je da imas sve na jednom mestu i da to kontrolises kako tebi odgovara, ali sto kaze ivanhoe, sa mod_rewrite "nema da ne moze!" ![]() kad smo vec kod .htaccess-a, evo sta ja koristim za moj home-made cms. Kôd:
# .htaccess # Configure PHP and add source highlighting AddType application/x-httpd-php-source .phps php_value display_errors "0" php_value error_reporting "E_NONE" php_value magic_quotes_gpc "0" php_value magic_quotes_runtime "0" php_value expose_php "0" # Disable directory indexes Options -Indexes # Configure rewrite engine RewriteEngine On RewriteOptions MaxRedirects=10 # If http://www.someplace.com/index/ is requested, transform it and stop. # (otherwise, it will lead to error 500) RewriteCond %{REQUEST_URI} /index/ RewriteRule ^.+$ index.php [L] # # If an existing file is requested, allow direct access # # (if a directory contents should be protected, create .htaccess # file with following contents: # # order allow,deny # deny from all # # and save in directory you need. # RewriteCond %{SCRIPT_FILENAME} -f RewriteRule ^(.+)$ $1 [L] # If user enters http://www.someplace.com/something, check if something.php # exists in specified directory (/ in this case), and if it does, let user # access it. RewriteCond %{SCRIPT_FILENAME}\.php -f RewriteRule ^(.+)$ $1.php [L] # # Now do some magic: convert url of form # # http://www.someplace.com/subdir/mod/act/parm1/val1/ # # into # # http://www.someplace.com/subdir/index.php?subdir/mod/act/parm1/val1/ # # That allows script to parse all input parameters, and makes it possible to # move whole directory structure in some subdirectory, without modifications # in this file. In other hand, script has to figure out which part of param # string belongs to the path. # RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{REQUEST_URI} ^/(([^\.]+)?(/((.+)?(/(.+)?)?)?)?)?$ RewriteRule ^.+$ index.php?%2%3 [L] # eof .htaccess
__________________
"It’s important to have goals when you pet. Otherwise you’re just rubbing another mammal for no reason." - Scott Adams |
![]() |
![]() |
Alati teme | |
Način prikaza | |
|
|
![]() |
||||
Tema | Početna poruka teme | Forum | Odgovori | Poslednja poruka |
FFAASSion - DRUGO OKUPLJANJE | mprinc | Flash | 1 | 10. 02. 2009. 01:16 |
Struja ili nesto drugo? | bluesman | Hardware | 7 | 21. 07. 2008. 02:57 |
action="http ili https' ? | misk0 | (X)HTML, JavaScript, DHTML, XML, CSS | 6 | 11. 07. 2007. 20:39 |
.htaccess, http->https | oliver | Regular expression i htaccess | 3 | 07. 11. 2005. 20:29 |