@ra1nbra1n

Как сделать редирект в .htaccess?

Имеется такой код файла .htaccess:
#RewriteEngine On

RewriteRule ^price/([^/]*)\.html$ /cars/chip-price.php?section=$1 [L]

<IfModule mod_rewrite.c>
  # enable the rewrite engine
  RewriteEngine On
  # Set your root directory
  RewriteBase /

  # remove the .html extension
  RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
  RewriteRule (.*)\.html$ $1 [R=301]

  # remove index and reference the directory
  RewriteRule (.*)/index$ $1/ [R=301]

  # remove trailing slash if not a directory
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*)/ $1 [R=301]
 
  # forward request to html file, **but don't redirect (bot friendly)**
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteCond %{REQUEST_URI} !/$
  RewriteRule (.*) $1\.html [L] 
</IfModule>

ErrorDocument 404 /404.html

<ifModule mod_deflate.c>
  <IfModule mod_filter.c>
      AddOutputFilterByType DEFLATE text/plain text/html
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
      AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/rss+xml
      AddOutputFilterByType DEFLATE application/json
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon
  </ifModule>
</ifModule>


Помогите пожалуйста настроить редирект с https://site.ru/blog/article.php?id=1 на https://site.ru/blog/article-1
  • Вопрос задан
  • 40 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы