I
I
Ivan2018-12-05 07:47:24
htaccess
Ivan, 2018-12-05 07:47:24

How to fix .htaccess to remove news from url?

In cms, all news opens with a predefined category news
.htaccess

RewriteRule ^news/(.*)/(.*)$ news.php?id=$1&slug=$2
How to remove news?
Did so
RewriteRule ^(.*)/(.*)$ news.php?id=$1&slug=$2
works, but now 404 error doesn't work (performs permanent redirects), its code is in .htaccess
RewriteRule ^not-found$ notfound.php

and because of this, fonts files are not available.
Addresses are available without a slash and with a slash at the end of the url.
All .htaccess
DirectoryIndex index.php

AddDefaultCharset UTF-8

<ifModule mod_rewrite.c>

RewriteEngine on


RewriteRule ^category/(.*)/(.*)$ category.php?id=$1&slug=$2
RewriteRule ^source/(.*)/(.*)$ source.php?id=$1&slug=$2

RewriteRule ^(.*)-(.*)$ news.php?id=$1&slug=$2

RewriteRule ^page/(.*)/(.*)$ page.php?id=$1&slug=$2
RewriteRule ^search/(.*)$ search.php?q=$1

RewriteRule ^not-found$ notfound.php

RewriteRule ^rss.xml$ rss.php
RewriteRule ^sitemap-(.*).xml$ sitemap.php?id=$1
RewriteRule ^categories-sitemap.xml$ categories-sitemap.php

</ifModule>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2018-12-05
@9StarRu

show links which are and which should be

D
dodo512, 2018-12-05
@dodo512

In the original, such links
https://site.ru/news/50/ostorozhno
are needed such as
https://site.ru/50-ostorozhno
, preferably at the end with or without a slash, now both options work.

If needed at the end/
Well, add your 404 page.
ErrorDocument 404 /notfound.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question