So basically I have my website and I'm trying to make it compatible with everything.
You go to the page: /Page_Name
But the page Page_Name does not exist but the 404 page is what handles the the request. I'm almost using it as a PHP GET command.
Web browsers work, but some other scripts fail because HTTP returns 404.
How can I fix this without creating files for every page? Can I use the .htaccess file to make the "GET" command work without "?Name=Page_Name" ?
You can use this rule as catch all rule in your DOCUMENT_ROOT/.htaccess
file:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Then inside index.php
you can use $_SERVER['REQUEST_URI']
to check what the original URI is.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.