Loading... 代码使用教程:打开宝塔面板 – 网站 – 设置 -伪静态。以下代码适用于Chevereto 3.x 。 Nginx URL rewriting规则: ``` # Context limits client_max_body_size 20M; # Disable access to sensitive files location ~* (app|content|lib)/.*\.(po|php|lock|sql)$ { deny all; } # Image not found replacement location ~ \.(jpe?g|png|gif|webp)$ { log_not_found off; error_page 404 /content/images/system/default/404.gif; } # CORS header (avoids font rendering issues) location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ { add_header Access-Control-Allow-Origin "*"; } # Pretty URLs location / { index index.php; try_files $uri $uri/ /index.php$is_args$query_string; } ``` Apache HTTP Server URL rewriting规则: ``` <Directory /var/www/html> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> ``` Apache虚拟主机 `.htaccess`(在网站根目录/) ``` # Disable server signature ServerSignature Off # Enable CORS across all your subdomains (replace dev\.local with your domain\.com) # SetEnvIf Origin ^(https?://.+\.dev\.local(?::\d{1,5})?)$ CORS_ALLOW_ORIGIN=$1 # Header append Access-Control-Allow-Origin %{CORS_ALLOW_ORIGIN}e env=CORS_ALLOW_ORIGIN # Header merge Vary "Origin" # Disable directory listing (-indexes), Multiviews (-MultiViews) Options -Indexes Options -MultiViews <IfModule mod_rewrite.c> RewriteEngine On # If you have problems with the rewrite rules remove the "#" from the following RewriteBase line # You will also have to change the path to reflect the path to your Chevereto installation # If you are using alias is most likely that you will need this. #RewriteBase / # 404 images # If you want to have your own fancy "image not found" image remove the "#" from RewriteCond and RewriteRule lines # Make sure to apply the correct paths to reflect your current installation RewriteCond %{REQUEST_FILENAME} !-f RewriteRule images/.+\.(gif|jpe?g|png|bmp|webp) - [NC,L,R=404] #RewriteRule images/.+\.(gif|jpe?g|a?png|bmp|webp) content/images/system/default/404.gif [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpe?g|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|webp|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ [NC] RewriteRule . index.php [L] </IfModule> ``` <hr class="content-copyright" style="margin-top:50px" /><blockquote class="content-copyright" style="font-style:normal"><p class="content-copyright">版权属于:大漠孤狼</p><p class="content-copyright">本文链接:<a class="content-copyright" href="https://www.dmgls.com/1275.html">https://www.dmgls.com/1275.html</a></p><p class="content-copyright">转载时须注明出处及本声明</p></blockquote> Last modification:December 13th, 2021 at 09:57 pm © 允许规范转载 Support 如果觉得我的文章对你有用,请随意赞赏 Appreciate the author