How to create a directory, such as URLs for each page on a website

I have a content site that spreads over multiple pages, but there is only 1 index.php file that retrieves data from the page-based database.

For now, the direction of the URL should be something like domainname.com/Page/content.php?page=3

I noticed that on several sites there is a directory similar to the structure for URLs like:

domainname.com/Page/3

I know how to change it to domainname.com/Page/?page=3, but I want to delete a part ?page.

How can I do this, without individually creating a directory for each page, the content continues to grow, therefore, changes for each page.

thank

+3
source share
2 answers

mod_rewrite, "" URL,

EDIT:

: domainname.com/Page/3

: domainname.com/Page/content.php?page=3

.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z]*)/(.*)$ /content.php/$1/page=$2 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /error_with_mod_rewrite.html
</IfModule>

, var , .

+4

"URL Rewrites" - , URL. -. URL- Apache. ,

Apache Mod_Rewrite.

Nginx "Rewrite" "Try_Files".

Cherokee , - .

, , . , , . -.

0

Source: https://habr.com/ru/post/1768475/


All Articles