M
M
Mitya ToDaSyo2019-03-28 05:49:18
PHP
Mitya ToDaSyo, 2019-03-28 05:49:18

What is the best way to implement url processing?

Good night!) I don’t even know how to describe the problem that I came up with myself)))
In a nutshell - I wanted a site with dynamic content loading via ajax, while I wanted to hide the real url addresses where the request is sent.
As a result, I send all requests to one Php file through the js function, the name variable is passed in the request, depending on what value this variable contains, the address of the handler is formed and it is pulled up through include to process the request.
Links have an appearance site.ru/page1while the real address site.ru/pages/page1.php
Through jquery.history I try to somehow manage this disgrace. Everything works, it goes back and forth, everything is fine until you refresh the page. Naturally, a 404 error ... I didn’t do any htaccess settings, because I don’t know how )))
The question is: what is the best way to solve the problem? So far, only one option comes to my mind that I can implement with my knowledge. Parse the url using php and follow the old pattern. But it seems to me that there is another way, perhaps just through htaccess?

some more letters

ps: it is planned that the links will have only one level, i.e. site.ru/page1/catIt will NOT, but links can drag 2-3 variables with them. I haven’t reached this point yet, so I’m at a loss to say what they will look like, or rather, what separator will be used after the main url, I think it’s like or there will be something else site.ru/page1?dt_begin=.......&dt_end=.......instead !? ?for example :?! But that's another question...

Don't ask me why, I'm just curious...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mitya ToDaSyo, 2019-03-28
@dimastik1986

I did it, everything is ok, maybe it will be useful to someone ...

RewriteEngine On
RewriteBase /pages

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

ErrorDocument 401 /errors/401.php
ErrorDocument 403 /errors/403.php
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php

I
irishmann, 2019-03-28
@irishmann

mod_rewrite for Apache, and instructions for creating CNC (human-readable urls)
tyts and tyts

N
Northern Lights, 2019-03-28
@php666

I wanted to hide the real url addresses where the request is sent.
it doesn't make any sense.
virtual/request/ address
is no different from
real/request/
from the point of view of the external client requesting information. the only reason for hiding addresses is aesthetic.
Well, on - CNC in PHP. Stay away from ModeRewrite rules. The only one...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question