【问题标题】:How to configure htaccess for localhost?如何为本地主机配置 htaccess?
【发布时间】:2013-10-07 12:50:45
【问题描述】:

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

我有以下代码 -

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。

我在这里遗漏了什么/出了什么问题?

谢谢。

【问题讨论】:

  • 你要发送什么 URL 到你的网络服务器?
  • 但我在您的.htaccess 中没有看到任何规则,它将参数1、参数2 等添加到您的查询字符串中。
  • @anubhava - 我编辑了问题。检查“#Other rules”行上方的规则。
  • 根据最后一条规则,URL 应始终以 .html 结尾。但你的例子是http://mysite.local/abc/value1/value2/

标签: php apache .htaccess localhost


【解决方案1】:

你没有在RewriteBase添加你的网站目录

RewriteBase /projectfolder/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-12
    • 2014-07-13
    • 2011-11-13
    • 2011-01-10
    • 2017-07-11
    • 1970-01-01
    • 2015-08-08
    • 2017-04-04
    相关资源
    最近更新 更多