Написание чистых URL с помощью .htaccess

Обновить — Хорошо, спасибо всем за ваши тесты, это действительно помогло. Код хороший. У меня не было абсолютных ссылок «/». (Из-за перемещения из папки public_html).

Только 2 проблемы у меня сейчас.

1.) Замените «^ achilles» на «^ ([0-9a-zA-Z _-] +)», и миниатюры не появятся (данные параметров не переносятся ???)

2.) Как я могу сделать http://funkygames.co/games/achilles/achilles/1 стать еще короче как http://funkygames.co/games/achilles Или параметры являются абсолютно обязательными.

# Turn Rewrite Engine On
RewriteEngine on

# Set the base to /games/ so we need not include it in the rules
RewriteBase /games/

#Rewrite for achilles.php?games_path=xxxxxxxxxx.yyy&category_id=zzz
RewriteRule ^achilles/(.*)/([0-9]+) $1.php?games_path=$1.swf&category_id=$2 [NC,L]

Где я узнал: www.youtube.com/watch?v=1pbAV6AU99I


РЕШИТЬ! Спасибо вам, ребята.
Решение:

# Turn Rewrite Engine On
RewriteEngine on

# Set the base to /games/ so we need not include it in the rules
RewriteBase /games/

#Rewrite for achilles.php?games_path=xxxxxxxxxx.yyy&category_id=zzz
RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+) $1.php?games_path=$1.swf&category_id=$2 [NC,L]

www.funkygames.co/games/achilles/1

0

Решение

Вы можете использовать следующий код в public_html / htaccess

# Turn Rewrite Engine On
RewriteEngine on

#Rewrite for achilles.php?games_path=xxxxxxxxxxxxx&category_id=x
RewriteRule ^(?:(achilles|games)/)?([0-9a-zA-Z_-]+)/([0-9]+)/?$ /achilles.php?games_path=$1.swf&category_id=$2 [NC,L]

Это перепишет:

или же

или же

в

  • /achilles.php?games_path=achilles.swf&category_id = 1
0

Другие решения

в .htaccess файл хранится в games папку, вставьте следующее:

RewriteEngine On

# Set the base to /games/ so we need not include it in the rules

RewriteBase /games/

# Rewrite {something}/{id} to {something}.php?games_path={something}&category_id={id}
# Examples: achilles/1 -> achilles.php?games_path=achilles.swf&category_id=1
#           other/3 -> other.php?games_path=other.swf&category_id=3

RewriteRule ^([0-9a-z]+)/(\d+)/?$ $1.php?games_path=$1&category_id=$2 [NC,L]

В этом примере завершающий слеш делается необязательным. Если вы не хотите использовать косую черту, удалите /? из шаблона запроса. Также в этом примере предполагается, что первая часть шаблона запроса будет соответствовать существующему файлу PHP. Если вы хотите использовать только achilles.phpзатем заменить $1.php с achilles.php,

0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector