I’m using a host that will only allow PHP files to be located in a subdir called /cgi/
But now all my links are /cgi/..
Excuse my daftness, but can I write a rewrite in my .htaccess file to make the site think that /cgi/ is the root so that all my links and the site itself appears to be in the root?
This is what I have but its causing a 500 error :
# Turn on rewrites.
RewriteEngine on
# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?thegrancenturions.com$
# Only apply to URLs that aren't already under folder.
RewriteCond %{REQUEST_URI} !^/cgi/
# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /cgi/$1
# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?thegrancenturions.com$
RewriteRule ^(/)?$ cgi/index.php [L]
I’ve not tested it, but something similar to this ought to work. You may also need to add a
RewriteCondwhich checks that incoming requests are not for/cgi/..