简体   繁体   中英

How do I get the status code 307 instead of 200? I am using apache2 in ubuntu 18.04

Below is my conf file:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/kiran

    RewriteEngine On
    RewriteCond %{DOCUMENT_ROOT}/index.html -f
    RewriteCond %{SCRIPT_FILENAME} !index.html
    RewriteRule ^.*$ /index.html [R=307,L]
    ErrorDocument 307 /index.html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

And when I'am doing curl it gives me below status code -->

# curl -iL localhost
HTTP/1.1 307 Temporary Redirect
Date: Sat, 28 Mar 2020 09:36:49 GMT
Server: Apache/2.4.29 (Ubuntu)
Location: http://localhost/index.html
Last-Modified: Fri, 27 Mar 2020 15:55:07 GMT
ETag: "239-5a1d8201d0033"
Accept-Ranges: bytes
Content-Length: 569
Content-Type: text/html

HTTP/1.1 200 OK
Date: Sat, 28 Mar 2020 09:36:49 GMT
Server: Apache/2.4.29 (Ubuntu)
Last-Modified: Fri, 27 Mar 2020 15:55:07 GMT
ETag: "239-5a1d8201d0033"
Accept-Ranges: bytes
Content-Length: 569
Vary: Accept-Encoding
Content-Type: text/html

My requirement is that when I hit the page it gives me 307 for all the contents.

It looks like it's doing exactly what you asked. Your client got a 307 and was redirected the one URL you have excluded from the rewrite.

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