Htaccess - Redirect all requests to a single file every time

0

I'm trying to use a .htaccess file to redirect all requests to a single file, but I'm facing some problems.

My .htaccess looks like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

My index.php file is in the same directory as the .htaccess file, and I also have a page1.php file in that directory. My problem is when I access:

localhost / pagina1.php

When I specify the file extension, it is processed, rather than redirecting to index.php

How could I even make the request redirect to the index.php file without affecting CSS and JS imports?

    
asked by anonymous 18.08.2018 / 04:18

1 answer

1

It is a half-word solution, you can find better searching on google (And yes, it has, you should search before posting question here in Stack face: /)

Use the following code in your htaccess

NOTE: If you are not very knowledgeable about .htaccess and are already using one, backup it, create a new one, and paste the following into it:

RewriteEngine on
RewriteCond $1 !^(index\.php|style\.css|js\.js)
RewriteRule ^(.*)$ /index.php/$1 [L]

Where% are files that should not undergo the redirect rule , with style.css (file.ext) | < Separated from files or be RewriteCond $1 !^(index\.php|style\.css|js\.js) etc ....

I hope it helps:)

    
18.08.2018 / 04:40