V
V
vasyok282018-05-04 13:30:23
htaccess
vasyok28, 2018-05-04 13:30:23

How to configure .htaccess for routing correctly?

I've been trying to set up .htaccess correctly for several days, but I just can't get what I want.
If the user enters:
www.site.com redirect to site.com
www.site.com redirect to site.com
site.com/article redirect to site.com/article/
There is also a problem if the user enters site.com/index.php /article also works like site.com/article

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php?$1 [QSA,L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Ainur Valiev, 2018-05-04
@vaajnur

these are the simplest redirects. examples - a cloud.

E
Evgeny Kramor, 2018-05-04
@exgod

.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
PHP Routing Library

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question