Pregunta

I currently have redirects (using IIRF, but i believe this to be the same as .htaccess rules) set up so that all files don't get redirected, and just go straight to the filepath in the URL, but everything else gets redirected to /index.php Using the code below:

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]

I need it to also redirect any .php file (but only .php files) to index.php (same as the second rule)

In summary, 'www.example.com/foo' AND 'www.example.com/foo.php' both need to go to the index page, but 'www.example.com/foo.js' and 'www.example.com/foo.css' (etc!) do not.

¿Fue útil?

Solución

Try:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]

Otros consejos

I think, you need something like this

RewriteCond %{REQUEST_FILENAME} *.php$
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top