
Adres w przeglądarce wygląda mniej więcej tak: /index.php?mode=jakis_modul
za obsługę modułów odpowiada kod:
<?php // należy wkleić plik do prawej kolumny // zmienna $modulesArray przechowuje listę modułów, jakie mają być dostępne // funkcja files2array pobiera nazwy plików i wstawia je do tablicy // oczywiscie robi to przy każdym przeładowaniu strony // aby nieco przyśpieszyć pracę skryptu można zrezygnować z użycia tej funkcji i z
definować moduły ręcznie // wtedy zmianne $modulesArray powinna wyglądać mniej więcej tak $modulesArray = a
rray('add.php', 'best.php', ...); $modulesArray = files2array(PATH_MODULES); $include = $_GET['mode']; } else { $include='main'; } ?>
nie miałem doczynienia wcześniej z mod_rewrite, wrzuciłem do pliku .htaccess regułkę:
Kod
RewriteEngine On
RewriteRule ^mode-([a-zA-Z0-9_]*).html /index.php?mode=$1 [L]
RewriteRule ^mode-([a-zA-Z0-9_]*).html /index.php?mode=$1 [L]
i pojawiła się strona error'a 500. Zobaczyłem, co wywala mi phpinfo() - w Loaded Modules nie ma mod_rewrite. Pogooglowałem nieco, aby znaleźć jak się włącza mod rewrite w apache. Pomocna okazał się stronka http://enarion.net/web/apache/htaccess/mod_rewrite-on-suse/
ZZrobiłem tak, jak pisali:
Kod
1. Edit the file /etc/sysconfig/apache2 as root:
1. search for APACHE_MODULES, you should find a line like this
APACHE_MODULES="suexec access actions alias auth auth_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif userdir ssl php4"
2. Add rewrite to the content in the list between the "
3. Save the changes and quit
2. run SuSEconfig to update the apache configuration files
3. run /etc/init.d/apache2 restart to restart the Apache server
1. search for APACHE_MODULES, you should find a line like this
APACHE_MODULES="suexec access actions alias auth auth_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif userdir ssl php4"
2. Add rewrite to the content in the list between the "
3. Save the changes and quit
2. run SuSEconfig to update the apache configuration files
3. run /etc/init.d/apache2 restart to restart the Apache server
zrestartowałem apache i już w Loaded Modules jest mod_rewrite
Odpaliłem skkrypt i nie wyskoczył już błąd 500. Chciałem sprawdzić, czy wszytko działa i zamiast
/index.php?mode=best wpisuję /mode-best.html i wyskakuje error 404 :/
Skryptu narazie nie zmieniałem, bo chciałem zobaczyć, czy będzie działało - nie wiem teraz, czy mam źle skonfigurowany serwer(na SuSE 9.3), czy w regułkach jest coś nie tak....
bardzo proszę o pomoc...