Answer the question
In order to leave comments, you need to log in
How to hide page format in url but not in php?
Hello! I want to hide the page format, for example, instead of /index.php it should turn out to be /index.
To do this, I used to do without htaccess, using php, I wrote a script that checks if there is a file with the php format in the necessary directives. Those. takes a url (for example index) and checks:
$page = "index";
if (file_exists("page/$page.php"))
include "page/$page.php";
Answer the question
In order to leave comments, you need to log in
Solution:
I specified the following in htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php
RedirectMatch 404 ^/page/.*
rinaz22 , the solution is correct, only at the same time you need to correctly make index.php, since "everything not found" is wrapped in it, including pictures, scripts, styles, etc.
Your index.php should quickly recognize and "kick back" all invalid urls. If someone puts < img src='your_site/non-existent_image.jpg'>
anywhere on the visited page , then your index.php will constantly twitch (the same will happen with your non-existent images). If index.php includes a bunch of other modules, and runs long enough, your site will crash.
And keep in mind that Googlebots regularly request urls like "any_abracadabra.html", expecting to get 404 Not found on them. Your index.php will intercept such urls, it's not bad that it gives the 404 code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question