I'm in the process of building an api and want to redirect all requests to v1/index.php
My folder structure is;
-htdocs
--v1
----index.php
This is my htaccess atm
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
I want all requests sent to api.example.co.uk
to go to v1/index.php
I want all requests sent to
api.example.co.uk
to go tov1/index.php
You can have this rule in root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} =api.example.co.uk
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ v1/index.php [L]
If you point you domain to /htdocs/v1/
folder and place inside with your index.php
this .htaccess
file it will redirect any request to index.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]