1

I have this on my htaccess:

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]

</IfModule>

And in the index.php I get the REQUEST_URI so I can know what page to display.

But I have another files .php, how to make that all php execution like http://domain.com/file.php directs to index.php?

If I the line "RewriteCond %{REQUEST_FILENAME} !-f" then the sitemap.xml is not working.

Sorry for my bad english, and thanks for your help!

1 Answer 1

1

You can have it like this:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # route all *.php to /index.php
    RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[/\s?] [NC]
    RewriteRule !^index\.php$ index.php [L,NC]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]

</IfModule>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.