0

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" ?

Joe
  • 33
  • 3

1 Answers1

0

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.

anubhava
  • 761,203
  • 64
  • 569
  • 643