A
A
Andrew2021-07-21 15:10:35
htaccess
Andrew, 2021-07-21 15:10:35

Two directories and htaccess?

Good day!
Help me understand what I'm doing wrong :)
The situation is as follows, I have a website and it has a catalog of services with a category page and a separate service page, I brought it to the form site name.ru/category/service name . Now I have a need to make a small catalog of products, I made a page with products, I made a page with a single product, but now I have a dilemma, how to make links with me and with products look the same as with services? HTACCESS now looks like this and if I try to follow a link like shop/taran I get an error 500

RewriteEngine on

AddDefaultCharset UTF-8

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)/index\.php$
RewriteRule ^(.*)$ %1/ [R=301,L]

RewriteCond %{THE_REQUEST} (/[^?/]+)\.php
RewriteRule ^%1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+category\.php\?category=([^\s]+) [NC]
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ category.php?category=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ category.php?category=$1

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+single\.php\?category=([^\s]+)&link=([^\s]+) [NC]
RewriteRule ^ %1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ single.php?category=$1&link=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ single.php?category=$1&link=$2

Help me figure out who is strong in this, I myself am already tired of fighting these mistakes :(

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question