Помогите разобраться с ЧПУ

12
WhiteFalke
На сайте с 16.09.2007
Offline
184
1404

Добрый день.

Пытался разобратся, не получилось.

Задача вроде простая

Есть ссылка вида www.site.ru/index.php?statya=medvedi

Необходимо что бы данная страница открывалась при вводе ссылки вида:

www.site.ru/statya/medvedi.html

В переменной statya могут быть как буквы и цифры так и знак "_"

J
На сайте с 22.02.2007
Offline
69
#1

На цмс делаете или сами...я на модексе делал так там надо файл .htaccess работать

Новости, музыка, литература в ярославле (http://www.bestseller.yaroslavl.ru)
WhiteFalke
На сайте с 16.09.2007
Offline
184
#2
jonicus:
На цмс делаете или сами...я на модексе делал так там надо файл .htaccess работать

Ну вот сам и хочу сделать. Я знаю что файл .htaccess нужен. Но что нужно прописывать

LEOnidUKG
На сайте с 25.11.2006
Offline
1774
#3

в .htaccess написать

RewriteEngine on

Options +FollowSymLinks

RewriteBase /

RewriteRule ^(.*)[/]?$ /index.php?statya=$1 [L,QSA]

P.S. не проверял, но работать должно...

✅ Мой Телеграм канал по SEO, оптимизации сайтов и серверов: https://t.me/leonidukgLIVE ✅ Качественное и рабочее размещение SEO статей СНГ и Бурж: https://getmanylinks.ru/ ✅ Настройка и оптимизация серверов https://getmanyspeed.ru/
WhiteFalke
На сайте с 16.09.2007
Offline
184
#4
LEOnidUKG:
в .htaccess написать
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteRule ^(.*)[/]?$ /index.php?statya=$1 [L,QSA]

P.S. не проверял, но работать должно...

Не работает, выдает страницу

Welcome to VertrigoServ

Change language

Information

Thanks for using this program and congratulations for your choice!

Packages:

Apache 2.0.59

PHP 5.2.3

Mysql 5.0.41

SQLite 3.4.0

PhpMyAdmin 2.10.2

SQLiteManager 1.2.0

ZendOptimizer 3.2.8

Loaded PHP extensions:

bcmath, calendar, com_dotnet, ctype, session, filter, ftp, hash, iconv, json, odbc, pcre, Reflection, date, libxml, standard, tokenizer, zlib, SimpleXML, dom, SPL, wddx, xml, xmlreader, xmlwriter, apache2handler, mbstring, bz2, curl, gd, mysql, mysqli, openssl, PDO, pdo_mysql, pdo_sqlite, SQLite, Zend Optimizer,

MySQL password status (for root):

You have to change the default MySQL password

Tools and links

PhpMyAdmin SQLiteManager

View phpinfo() screen View loaded PHP extensions Apache Server Information

VertrigoServ Project Page VertrigoServ Forum

Apache 2.0 documentation PHP Manual MySQL Manual phpMyAdmin Manual SQLite Manual

Copyright © 2004-2007 by Dariusz Handzlik

LEOnidUKG
На сайте с 25.11.2006
Offline
1774
#5

мне или кажеться или на хостинге нету мод_реврайт...

WhiteFalke
На сайте с 16.09.2007
Offline
184
#6
LEOnidUKG:
в .htaccess написать
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteRule ^(.*)[/]?$ /index.php?statya=$1 [L,QSA]

P.S. не проверял, но работать должно...

Изменил - RewriteRule ^(.*)[/]?$.html /index.php?statya=$1 [L,QSA]

Стало все грузится но сама переадресация не работает

J
На сайте с 22.02.2007
Offline
69
#7

у мя в файле .htaccess прописано

# MODx supports Friendly URLs via this .htaccess file. You must serve web

# pages via Apache with mod_rewrite to use this functionality, and you must

# change the file name from ht.access to .htaccess.

#

# Make sure RewriteBase points to the directory where you installed MODx.

# E.g., "/modx" if your installation is in a "modx" subdirectory. If you have

# problems with your .htaccess working at all, try un-commenting the first

# line above the "RewriteEngine On" directive.

#

# You may choose to make your URLs non-case-sensitive by adding a NC directive

# to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]

#Options +FollowSymlinks

RewriteEngine On

RewriteBase /

# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin

#RewriteCond %{HTTP_HOST} .

#RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]

#RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]

#

# or for the opposite domain.com -> www.domain.com use the following

# >>> DO NOT USE BOTH THE ABOVE AND BELOW <<<

#

#RewriteCond %{HTTP_HOST} .

#RewriteCond %{HTTP_HOST} !^www\.example-domain-please-change\.com [NC]

#RewriteRule (.*) http://www.example-domain-please-change.com/$1 [R=301,L]

# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent

# https://www.domain.com when your cert only allows https://secure.domain.com

#RewriteCond %{SERVER_PORT} !^443

#RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]

# The Friendly URLs part

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# Make sure .htc files are served with the proper MIME type, which is critical # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.

#AddType text/x-component .htc

# If your server is not already configured as such, the following directive

# should be uncommented in order to set PHP's register_globals option to OFF.

# This closes a major security hole that is abused by most XSS (cross-site

# scripting) attacks. For more information: http://php.net/register_globals

#

# To verify that this option has been set to OFF, open the Manager and choose

# Reports -> System Info and then click the phpinfo() link. Do a Find on Page

# for "register_globals". The Local Value should be OFF. If the Master Value

# is OFF then you do not need this directive here.

#

# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :

#

# Your server does not allow PHP directives to be set via .htaccess. In that

# case you must make this change in your php.ini file instead. If you are

# using a commercial web host, contact the administrators for assistance in

# doing this. Not all servers allow local php.ini files, and they should

# include all PHP configurations (not just this one), or you will effectively

# reset everything to PHP defaults. Consult www.php.net for more detailed

# information about setting PHP directives.

#php_flag register_globals Off

# For servers that support output compression, you should pick up a bit of

# speed but un-commenting the following lines.

#php_flag zlib.output_compression On

#php_value zlib.output_compression_level 5

# The following directives stop screen flicker in IE on CSS rollovers. If

# needed, un-comment the following rules. When they're in place, you may have

# to do a force-refresh in order to see changes in your designs.

#ExpiresActive On

#ExpiresByType image/gif A2592000

#ExpiresByType image/jpeg A2592000

#ExpiresByType image/png A2592000

#BrowserMatch "MSIE" brokenvary=1

#BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1

#BrowserMatch "Opera" !brokenvary

#SetEnvIf brokenvary 1 force-no-vary

LEOnidUKG
На сайте с 25.11.2006
Offline
1774
#8

тогда пробуй:

RewriteEngine on

Options +FollowSymlinks

RewriteBase /

RewriteRule ^([A-Za-z0-9_-]+)[/]?$ /index.php?page=$1 [L,QSA]

WhiteFalke
На сайте с 16.09.2007
Offline
184
#9
LEOnidUKG:
тогда пробуй:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^([A-Za-z0-9_-]+)[/]?$ /index.php?page=$1 [L,QSA]

Я может не так ввожу просто ссылку преобразованную.

Тут я так понимаю связь с переменной page.

Как ссылка должна выглядеть?

www.site.ru/index.php?page=privet

Так?

www.site.ru/page/privet

Или так www.site.ru/page/privet.html

И так и так попробывал не работает.

WhiteFalke
На сайте с 16.09.2007
Offline
184
#10
LEOnidUKG:
тогда пробуй:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^([A-Za-z0-9_-]+)[/]?$ /index.php?page=$1 [L,QSA]

И еще наверное мне же сслки мне нужны вида www.site.ru/news-1.html а не www.site.ru/news/1.html

От первого варианта возникнут проблемы с путями до папок стилей, рисунков и прочего

12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий