当我的网站位于我托管的根目录中时,一切正常。但是,我必须将我的网站文件移动到子目录。
旧:
/www/*
电流:
/www/websites/example
现在,我可以访问我网站的主页,但是当我访问我网站的其他页面时出现错误。
example.com/1234/title_of_url -> example.com/index.php?qa-rewrite=1234/title_of_url
但是当我访问该示例页面时,我收到以下错误。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
这是我的.htaccess
文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
注意:我已将文件移至我的/www/
目录,并且工作正常。所以我想我错过了将websites/example
放在.htaccess
答案 0 :(得分:0)
在站点根目录中使用此规则.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/websites/ [NC]
RewriteRule .* websites/example/$0 [L]
然后在websites/example/.htaccess
:
RewriteEngine On
RewriteBase /websites/example/
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!index\.php$).*$ index.php?qa-rewrite=$0 [NC,L,QSA]