A
A
Artem2014-07-11 08:21:51
Apache HTTP Server
Artem, 2014-07-11 08:21:51

Why does the CNC call give a 404 error?

I decided to understand the operation of the CNC and make my own simple example.
There is a page /projects/index.php - displays a list of projects
It is necessary that at /projects/nazvanie-proekta/ - a description of the project is displayed.
/projects/ - opens
/projects/nazvanie-proekta/ - gives 404 error
In the .htaccess file I wrote as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^projects/([a-zA-Z0-9\-]*)/$ /projects/index.php?pr_url=$1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2014-07-11
@Rchee

If .htaccess is in the root of the site then
if in projects then

RewriteRule ^([a-zA-Z0-9\-]+)/?$ index.php?pr_url=$1

A
Alexey Pavlov, 2014-07-11
@lexxpavlov

there is no character / after the ^ character
The ^ character denotes the beginning of a line, so ^projects does not match the /projects line
And it is better to change the asterisk to a plus sign, otherwise the /projects// lines will fall under the pattern in this variant.
Final rule:
RewriteRule ^/projects/([a-zA-Z0-9\-]+)/$ /projects/index.php?pr_url=$1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question