How best to implement the processing of the url?

Good night!) Don't even know how to describe the problem, which he himself invented)))

In a nutshell, I wanted a website with dynamic content loading via ajax, in this case I wanted to hide the real url you send the request.

In the js function send all requests to one Php file, the query is passed the variable name, depending on which value contains this variable, formed the address of a handler and pulls it through an include to handle the request.

Links have the form site.ru/page1 while the real address site.ru/pages/page1.php

Using jquery.history trying this mess to manage. Everything works there-here goes, all is well, until you do refresh the page. Naturally, the 404 error... Any settings htaccess I did, for I do not know )))

Actually a question: how to solve the problem? I can think of is only one option which I with their knowledge can implement. To make the parsing a url using php and then on the old scheme. But it seems to me that there is another way, perhaps just using htaccess?

some more letters

ps: it is planned that the links will have only one level, i.e. site.ru/page1/cat will NOT, but the links can drag along with 2-3 variables. Up to this point has not yet reached, so I cannot say what they will be or rather what kind of separator is used after the main url, I think the type of site.ru/page1?dt_begin=.......&dt_end=....... or instead of ? there will be something else!? for example :?! But this is another question...


don't ask me why, just wondering...
March 19th 20 at 08:56
3 answers
March 19th 20 at 08:58
Solution
did everything OK, can someone come in handy...

RewriteEngine On
RewriteBase /pages

RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteRule ^([^.]+)$ $1.PHP [NC,L]

An ErrorDocument 401 /errors/401.php
An ErrorDocument 403 /errors/403.php
An ErrorDocument 404 /errors/404.php
An ErrorDocument 500 /errors/500.php
March 19th 20 at 09:00
mod_rewrite for Apache, and how to create NC (human-friendly url)
tyts and tyts
Yes, thank you! was sorta understand, but still thank you!

if not difficult, could not look, whether correctly I made
and this time, as I would all this make links like site.ru/order.add, site.ru/order.edit which would have led to the file in the folder /pages name order_add.php, order_edit.php accordingly, for the other pages similar? well, I don't like the underscore in the url ))

RewriteEngine On
RewriteBase /pages

RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* <a href="https://%{SERVER_NAME}%{REQUEST_URI}">https://%{SERVER_NAME}%{REQUEST_URI}</a> [R=301,L]
RewriteRule ^([^.]+)$ $1.PHP [NC,L]


An ErrorDocument 401 errors/401.php
An ErrorDocument 403 errors/403.php
An ErrorDocument 404 errors/404.php
An ErrorDocument 500 errors/505.php
- alysa.Rutherfo commented on March 19th 20 at 09:03
March 19th 20 at 09:02
I wanted to hide the real url you send the request.
this makes no sense.
virtual address/request/
no otklikaetsya from
real/request/
from the point of view of the external client requesting the information. the only reason to conceal andresov aesthetic.

well, on - CNC PHP. Away from ModeRewrite rules. One that...
this makes no sense.


send all requests to one Php file, the query is passed the variable name, depending on which value contains this variable, formed the address of the handler
- alysa.Rutherfo commented on March 19th 20 at 09:05

Find more questions by tags htaccessPHP