如何为本地主机配置 htaccess


How to configure htaccess for localhost?

我正在进行项目维护,我需要配置 htaceess 文件以在本地主机上运行项目,因为我创建了一个虚拟主机来运行该项目。

我有以下代码 -

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www'.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^(?!(text1|text2|text3)'.html|common-secure'.php|images'/|css-secure'/|javascript'/).* http://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteRule ^index.(.*)'.html$ index.php?langurl=$1&%{QUERY_STRING}
RewriteRule ^index.html$ index.php?%{QUERY_STRING}
RewriteRule ^city/(.*)'.(.*)'.(.*)'.html$ city.php?cityurl=$1&langurl=$2&page=$3&%{QUERY_STRING}

#Other rules

我用以下方式替换了上面的最后 4 行和第 5 行 -

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

但是,仍然无法加载js插件。此外,不会将查询字符串参数(如"langurl")获取到 $_GET 中。

我在这里错过了什么/出了什么问题?

谢谢。

您缺少在RewriteBase中添加网站目录

RewriteBase /projectfolder/