mardi 2 mai 2017

Getting Laravel htaccess to listen to my rewrites

I'm trying to rewrite some old site pages to routes on my shiny new Laravel site. I understand in principle how .htaccess works, but there's a line in the default Laravel .htaccess which (I think) is throwing my own rewrites. So, this is something like what I am trying to do:

RewriteRule ^user/(\d+)*$ ./users

However, Laravel already has this:

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

Which effectively says "If the user request is for any file or folder that does not exist, pipe their request through to index.php" - the [L] meaning that this is the last rule for these conditions.

My problem with this is, where do I put my rewrite instructions? If I put it after that rule then surely my rewrite will be ignored as everything is already being sent to index.php (if htaccess rules are sequential)

If I put my rule before Laravel's default rules, does that mean that my rule will mess up what Laravel is trying to do? At the moment, wherever I put my rule, I just get various result ranging from a 500 error to a blank page with no content.

How can I integrate my own rules into Laravel's .htaccess file without stepping on Laravel?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire