我使用的主机只允许PHP文件位于名为/cgi/
但现在我所有的链接都是/cgi/..
请原谅我的愚蠢,但我可以在我的.htaccess文件中写一个重写,让网站认为/cgi/
是根,以便我的所有链接和网站本身都显示在根目录中吗?
这就是我所拥有的,但它导致500错误:
# 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]
答案 0 :(得分:0)
RewriteEngine On
RewriteRule ^(.+?)$ cgi/$1 [QSA,L]
我没有对它进行测试,但类似的东西应该可行。您可能还需要添加RewriteCond
,以检查传入的请求是否不适用于/cgi/..