我在这个问题上花了5天时间,Apache无法识别我的.htaccess
文件。它位于我htdocs/build
旁边的index.html
。我已激活mod_rewrite
,AllowOveride
已设置为All
。当我给它随机文本时,该文件甚至不会抛出500错误,它不会记录。另一方面,完全相同的httpd.conf
,react.js
版本和.htaccess
在我老板的电脑上完美运行。如果我将.htaccess
代码(其SPA的重定向代码)放入<Directory "${SRVROOT}/htdocs/build">
,则运行时没有错误。
我的.htaccess
文件中的代码是:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
我正在运行Windows 7,我已经在Apache Haus 2.4.33上进行了测试,现在它在2.4.12上运行(以验证它是否与版本33有关)。
winnt:notice] [pid 4092:tid 484] AH00424: Parent: Received restart signal -- Restarting the server.
[Tue Apr 03 13:47:25.922966 2018] [ssl:warn] [pid 4092:tid 484] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 03 13:47:25.922966 2018] [mpm_winnt:notice] [pid 4092:tid 484] AH00455: Apache/2.4.12 (Win64) OpenSSL/1.0.1l configured -- resuming normal operations
[Tue Apr 03 13:47:25.923966 2018] [mpm_winnt:notice] [pid 4092:tid 484] AH00456: Apache Lounge VC11 Server built: Jan 28 2015 14:29:16
[Tue Apr 03 13:47:25.923966 2018] [core:notice] [pid 4092:tid 484] AH00094: Command line: 'C:\\Apache\\Apache24\\bin\\httpd.exe -d C:/Apache/Apache24'
[Tue Apr 03 13:47:25.924966 2018] [mpm_winnt:notice] [pid 4092:tid 484] AH00418: Parent: Created child process 988
[Tue Apr 03 13:47:26.245998 2018] [ssl:warn] [pid 988:tid 168] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Apr 03 13:47:26.797053 2018] [mpm_winnt:notice] [pid 988:tid 168] AH00354: Child: Starting 64 worker threads.
[Tue Apr 03 13:47:27.798153 2018] [mpm_winnt:notice] [pid 5308:tid 168] AH00364: Child: All worker threads have exited.
答案 0 :(得分:0)
[已解决] npm run build
生成的htaccess文件为其提供了文件扩展名.txt
,我使用命令将其删除了
rewrite .htaccess.txt .htaccess
在命令提示符