1

Recently I've been using vagrant for a university assignment and we have to use the single entry point concept by routing everything through the index.php page. Naturally this makes Urls quite ugly (for eg: index.php?page=bookings). So I tried using .htaccess files which work flawlessly with standard php using Xampp.

But I can't get the URLs to redirect in vagrant when I place the .htaccess file in the public folder where the index.php resides. The file path is vagrant\websites\default\public.htaccess

.htaccess file code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?page=$1 [QSA,L]

Is it not working because Vagrant uses Nginx server? Any sort of help would be appreciated

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • What is the url you are hitting? Please post a sample of url here, thank you. – RavinderSingh13 May 06 '21 at 12:28
  • about should redirect to index.php?page=about . RewriteRule about index.php?page=about . The above rewrite rule would be used if the wildcards weren't used – UpretiKushal101 May 06 '21 at 12:31
  • 1
    `Is it not working because Vagrant uses Nginx server?` => if what your saying is that you know that your vagrant machine used for this project is running nginx, the answer is [yes](/questions/35766676/how-can-i-use-an-htaccess-file-in-nginx) – Zeitounator May 07 '21 at 22:32
  • @Zeitounator ohh. thanks – UpretiKushal101 May 08 '21 at 06:03

0 Answers0