.htaccess

Proper .htaccess config for Next.js SSG

一世执手 提交于 2020-07-20 19:54:58
问题 NextJS exports a static site with the following structure: |-- index.html |-- article.html |-- tag.html |-- article | |-- somearticle.html | \-- anotherarticle.html \-- tag |-- tag1.html \-- tag2.html I'm using an .htaccess file to hide the .html extensions: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html Everything works flawlessly, EXCEPT: If I follow a link to domain/article it displays the article.html page, but my

Proper .htaccess config for Next.js SSG

心不动则不痛 提交于 2020-07-20 19:46:13
问题 NextJS exports a static site with the following structure: |-- index.html |-- article.html |-- tag.html |-- article | |-- somearticle.html | \-- anotherarticle.html \-- tag |-- tag1.html \-- tag2.html I'm using an .htaccess file to hide the .html extensions: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html Everything works flawlessly, EXCEPT: If I follow a link to domain/article it displays the article.html page, but my

How can I style a .htaccess password protection promp?

点点圈 提交于 2020-07-18 21:57:22
问题 I've just been messing around with setting a password protected directory on my webserver (so as to store hot copies of backups etc.) and was wondering if there's any way I may be able to style the password prompt that appears when a user attempts to access this page. As it stands nobody will notice my nice little note, which makes me sad. It seems to display similarly to a standard .js alert, though I've been unable to find a way to specify any css classes I may be able to alter, as the

How can I style a .htaccess password protection promp?

亡梦爱人 提交于 2020-07-18 21:57:18
问题 I've just been messing around with setting a password protected directory on my webserver (so as to store hot copies of backups etc.) and was wondering if there's any way I may be able to style the password prompt that appears when a user attempts to access this page. As it stands nobody will notice my nice little note, which makes me sad. It seems to display similarly to a standard .js alert, though I've been unable to find a way to specify any css classes I may be able to alter, as the

How to serve webp images using htaccess?

…衆ロ難τιáo~ 提交于 2020-07-16 06:48:23
问题 I would like to serve .webp images if the image (jpg or png) is available as webp. If not I want to show the jpg or png. RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)\.(jpe?g|png)(.*)$ $1.$2.webp [NC,L] AddType image/webp .webp The problem I need the final URL to be like: "myurl.com/foo.jpg.webp" If the webp file exists and if not I need: "myurl.com/foo.jpg" as a fallback solution. 回答1: If the requested URL ends in jpeg or png , you might test for

Blocked HTTP Methods are not returning HTTP 405 response

℡╲_俬逩灬. 提交于 2020-07-10 08:58:08
问题 How do I configure (ideally) Apache (or alternatively) PHP to respond specifically with an HTTP 405 when the request method is not GET or POST ? My Apache .htaccess attempt does block requests except it returns the incorrect HTTP 403 response: <LimitExcept GET POST> Order Allow,Deny Deny from all </LimitExcept> In PHP I've used the following at the absolute start of where requests are handled and it just gets completely ignored: if (!in_array($_SERVER['REQUEST_METHOD'],array('GET','POST'))) {

Remove a 301 redirect from previous website

那年仲夏 提交于 2020-07-09 03:24:05
问题 We made a new website for our client, Now the old website used a 301 redirect to send the user to a subfolder.. I've removed the old website and .htaccess, but the redirect is still in effect due to the caching. Is there any way to update or undo the 301? I can't imagine I have to send an email to all the website visitors telling them to clear their cache. Thank you! 回答1: TL;DR - There's not a way to remove it without clearing cache. Workarounds are (grabbed from here): Put legacy content

Remove a 301 redirect from previous website

旧城冷巷雨未停 提交于 2020-07-09 03:23:07
问题 We made a new website for our client, Now the old website used a 301 redirect to send the user to a subfolder.. I've removed the old website and .htaccess, but the redirect is still in effect due to the caching. Is there any way to update or undo the 301? I can't imagine I have to send an email to all the website visitors telling them to clear their cache. Thank you! 回答1: TL;DR - There's not a way to remove it without clearing cache. Workarounds are (grabbed from here): Put legacy content

htaccess redirect only if domain matches

房东的猫 提交于 2020-07-04 12:17:39
问题 I have a problem where I need to redirect my domain before it hits php. By the time it hits the ability to execute a header, it is too late. How can I do if (domain == 'www.example.com') redirect www.domain.com; in my .htaccess? 回答1: Using mod_rewrite RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R,L] 回答2: As of Apache 2.4 you can use an <If> Directive to achieve what you suggested: <If "req('Host') == 'www.example.com'">

XAMPP .htaccess AddEncoding

廉价感情. 提交于 2020-06-29 03:48:55
问题 I install no my MacOs HighSierra fresh XAMPP (osx-7.4.6-0-vm) and start it - server runs on IP 192.168.64.2 . Then I mount /opt/lampp and click to Explore . The Finder window open and I go to directory htdocs/ . Then inside htdocs I create folder assets and inside it I copy file alice.wasm (this file is compressed using brotli (br)). You can download this test (brotli compressed) file using this jsfiddle generator. Inside htdocs I create following .htaccess file <IfModule mod_mime.c> AddType