E
E
Evgeniy Samoilenko2014-07-18 15:24:53
PHP
Evgeniy Samoilenko, 2014-07-18 15:24:53

How to make CNC with PHP?

Good afternoon!
I set up the CNC in the project, everything works, I read a lot of manuals for setting up .htaccess, I tried different options, but only one thing does not work!
when using /test-test2-test3 - everything works fine
, and when using /test/test2/test3 - it starts looking for the /test/ directory and starts further from it.
.htaccess code:

AddDefaultCharset off
IndexOptions +Charset=UTF-8

DirectoryIndex index.php
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php?%{QUERY_STRING}

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
Dmitry Entelis, 2014-07-18
@samoilenkoevgeniy

This is strange, the code is correct, it works for me.
From myself, I can recommend all the same instead
of using the construction of the form
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

A
Alexander Glushchenko, 2014-07-18
@somenumboola

I doubt it, but try after
Add line ending character $
Thus:

#...
RewriteRule ^(.*)$ index.php?%{QUERY_STRING}
#...

C
cloud-habr, 2014-07-18
@cloud-habr

Try to implement
CNC like this in PHP. Stay away from ModeRewrite rules. A single one ...
or write everything manually

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z-]+)/test/([0-9]+)(/?)$ ?category=$1&page=$2

A
Alexey Bespalov, 2014-07-18
@nulldef

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?r=$1

A
Andrey Burov, 2014-07-18
@BuriK666

Add
RewriteBase /

T
toxa82, 2014-07-18
@toxa82

RewriteEngine On
RewriteBase /

# REQUEST_FILENAME - перенаправление всего, кроме существующих файлов
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L,QSA]

I get the entered uri from $_SERVER['REQUEST_URI']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question