简体   繁体   中英

.htaccess file is not recognized by Apache

I have spent 5 days on this issue, my .htaccess file is not recognized by Apache. It is located in htdocs/build beside my index.html . I have activated mod_rewrite , AllowOveride has been set to All . The file doesn't even throw a 500 Error when I give it random text, it doesn't log. On the other hand, the exact same httpd.conf , react.js build, and .htaccess run perfectly on my boss' computer. If I place the .htaccess code (its redirect code for an SPA) into <Directory "${SRVROOT}/htdocs/build"> it runs with no fault.

The code in my .htaccess file is:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

RewriteRule ^ index.html [L]

I am running Windows 7, I have tested this on Apache Haus 2.4.33 now it's running on 2.4.12 (to verify if it was an issue with version 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.

[SOLVED] the htaccess file generated by npm run build gave it a file extension .txt , I removed it using the command

    rewrite .htaccess.txt .htaccess

in command prompt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM