KPXD
KPXD

Reputation: 53

.htaccess redirect to index.php

My website : theexample.com I modified my .htaccess so that if visitors visits an unkown url it redirects directly to index.php with :

FallbackResource index.php

The problem is that it works only if there is one element after "theexample.com".

for example :

Upvotes: 1

Views: 145

Answers (2)

Michael
Michael

Reputation: 360

This is rewrite. Redirect only non-files links =)

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php

Example: url http://example.com/asdjivuhr/34tv3t will redirext to index.php BUT if you have files(css,js) http://example.com/script.js will stay untooched if file exists!

Upvotes: 0

anubhava
anubhava

Reputation: 785126

You must use absolute path of fallback resource not a relative one:

FallbackResource /index.php

Otherwise FallbackResource index.php will try to load index.php in the provided sub-path e.g. theexample.com/sh/fuisd/fhisdfh will try to load theexample.com/sh/fuisd/index.php which will cause failure as that path doesn't exist resulting in Internal Server Error.

Upvotes: 1

Related Questions