ANTICHAT.XYZ    VIDEO.ANTICHAT.XYZ    НОВЫЕ СООБЩЕНИЯ    ФОРУМ  
Баннер 1   Баннер 2
Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей. Здесь обсуждаются безопасность, программирование, технологии и многое другое. Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz
Вернуться   Форум АНТИЧАТ > Оффтоп > Forum for discussion of ANTICHAT
   
 
 
Опции темы Поиск в этой теме Опции просмотра

[Translation] Mod_Rewrite tutorial
  #1  
Старый 13.03.2007, 19:32
Аватар для Дрэгги
Дрэгги
Moderator - Level 7
Регистрация: 26.08.2005
Сообщений: 457
Провел на форуме:
4007686

Репутация: 1442
По умолчанию [Translation] Mod_Rewrite tutorial

mod_rewrite...what is it? As wiki says -

Цитата:
A rewrite engine is a piece of web server software used to modify URLs, for a variety of purposes.
i.e. some kind of module for a web server, enabling to modify links...In general, the rewrite engine itself exists both for apache and microsoft's IIS and even for java platforms =) In this particular article we're going to talk exactly about mod_rewrite for apache.

Everything we're gonna need is .htaccess file radically, if you already have it..then it's only need to finish writing some certain lines in it..and surely in case hoster hasn't installed this module yet, he should be kicked around a little..)

As for me personally I use full links in .htaccess, if you want to use relative links like /index.php?blabla=31337 then it's advisable to include the following lines in the file, which ,even though only a little bit, but speeds up the work

Цитата:
DocumentRoot /home/htdocs/www
<Directory /> Options FollowSymLinks
</Directory>
that is, in case you have a www site but the option isn't on then apache will be trying to find Index.php file first in /home/ then in /home/htdocs/ and in the end will stumble on /home/htdocs/www/index.php. This is nothing of course, but you'll still spare some hundredth parts of the second..) or you can write in every file before "rewrital on" the following phrase

PHP CODE:


Цитата:
Options +FollowSymLinks


Generally it is possible to find many ways to use in it..most popular of which - is the transformation of the link into some more readable look ) ..well, find me a man who would like the link such as

Цитата:
http://site.com/index.php?action=forum&forum=theme01
Let us transform it into..for instance

Цитата:
http://site.com/forum/someshit.htm

For this we will need to turn RewriteEngine itself on for starters:

PHP CODE:

Цитата:
RewriteEngine On
then we overwrite the url itself:


PHP CODE:

Цитата:
RewriteRule ^ ([a-z]+)/([a-z0-9]+).htm$ index.php?action=$1;forum=$2
Let's clarify things related to this quite simple construction...

RewriteRule simply sets the beginning of the overwrite line.

([a-z]+) indicates that everything before "slash" is replaced with small roman letters from a to z (everything is written into the $1 variable)

then after "slash" we see ([a-z0-9]+).htm
, that is, here we replace everything after "slash" with small roman letters from a to z and digits from 0 to 9 ($2 variable)
, and then add htm extension in the end of the url.

As you understand, such .htm files never actually were and will never be on your site, it's just that thus links are shown in a more comfortable way.

The most important here is to remember this order - how it goes after RewriteRule - firstly - how to transform and only then what to transform


As you understand that's in order to make forum fully overwrite links (urls) with parameters in htm look (not obligatory htm, it can be any kind of extension your imagination might create) for all existing transferrable by GET parameters...should it be a search, threads, forums, personal messages after all...the main thing is also not to overdo it = )

Original copyright: blackybr

English version translation: Дрэгги

Последний раз редактировалось Дрэгги; 05.04.2007 в 18:53..
 
Ответить с цитированием
 



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
[Translation] New Benchmark alternative or effective blind SQL-injection by Elekt NeMiNeM Forum for discussion of ANTICHAT 2 14.09.2007 19:43
[Translation] From sql-injection to root by p-range NeMiNeM Forum for discussion of ANTICHAT 0 20.04.2007 23:41
Hacking IIS Tutorial bxN5 Forum for discussion of ANTICHAT 1 14.03.2007 23:44



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT.XYZ