apache_conf CF7 404错误修复

错误<br/> GET https://domain.com/wp-json/contact-form-7/v1/contact-forms/3/fill/ 404 <br/> POST https://domain.com/wp- json / contact-form-7 / v1 / contact-forms / 3 / feedback / 404 <br/> <br/>另一个原因可以是:<br/> <br/> 1.如果你已经禁用了REST API(手动或例如使用Clearfy)<br/> 2.如果您使用插件加载过滤器(https://de.wordpress.org/plugins/plugin-load-filter/)并过滤CF7页面。

.htaccess
# Add trailing slash to the end of the link
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !^/wp-json
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js|xml)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]
# End Adding trailing slash to the end of the link

apache_conf 强制https

强制域使用HTTPS安全地提供服务(适用于任何站点)

.htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

apache_conf ssh配置文件

ssh配置文件

config
Host ubuntu
    Hostname localhost
    Port 2222
    User vagrant
    IdentityFile ~/vagrant/ubuntu1604/.vagrant/machines/default/virtualbox/private_key
    RemoteForward 1080 localhost:1080

apache_conf 启用gzip压缩

把它放到.htaccess中

enable-compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

apache_conf 启用浏览器缓存

把它放到.htaccess中

browser-caching
<IfModule mod_expires.c>
ExpiresActive On
AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresByType application/vnd.ms-fontobject "access 1 year"
ExpiresByType application/x-font-ttf "access 1 year"
ExpiresByType application/x-font-opentype "access 1 year"
ExpiresByType application/x-font-woff "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType text/html "access 1 hour"
ExpiresByType text/css "access 14 days"
ExpiresByType text/x-javascript "access 3 weeks"
ExpiresByType application/javascript "access 1 month"  
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType image/gif "access 2 months"
ExpiresByType image/png "access 2 months"
ExpiresByType image/jpg "access 2 months"
ExpiresByType image/jpeg "access 2 months"
ExpiresByType image/gif "access 2 months"
ExpiresByType application/pdf "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>

apache_conf 保护WordPress配置wp-config.php文件

WordPress配置文件wp-config.php包含您的WordPress数据库登录凭据。如果它被泄露,那么它将揭示可能使黑客完全访问您的网站的信息。 <br/> <br/>您可以通过使用.htaccess拒绝访问wp-config文件来添加额外的保护层。只需将此小代码添加到.htaccess文件即可。

table-prefix-change
<files wp-config.php>
order allow,deny
deny from all
</files>

apache_conf Apache .htaccess重定向

重定向ke域lain dengan通配符子域。

.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)(\.?)domain.com [NC,OR]
RewriteCond %{HTTPS_HOST} ^(.*)(\.?)domain.com [NC]
RewriteRule ^(.*)$ https://domain.org/$1 [L,R=301,NC]

apache_conf Localhost代理apache2

apache2和ssl的本地主机代理支持<br/> ispconfig

proxy localhost
ProxyPreserveHost On
SSLProxyEngine on
SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

ProxyPass / https://127.0.0.1:8080/ 
ProxyPassReverse / https://127.0.0.1:8080/ 

<Location />
Order deny,allow
Allow from all
</Location>

apache_conf 常见.htaccess重定向

常见.htaccess重定向

.htaccess
#301 Redirects for .htaccess

#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html

#Redirect an entire site:
Redirect 301 / http://www.domain.com/

#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/

#Redirect a sub folder to another site
Redirect 301 /subfolder http://www.domain.com/

#This will redirect any file with the .html extension to use the same filename but use the .php extension instead.
RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php

##
#You can also perform 301 redirects using rewriting via .htaccess.
##

#Redirect from old domain to new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

#Redirect to www location
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

#Redirect to www location with subdirectory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC]

#Redirect from old domain to new domain with full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]

#Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC]

Rewrite and redirect URLs with query parameters (files placed in root directory)

Original URL:

http://www.example.com/index.php?id=1
Desired destination URL:

http://www.example.com/path-to-new-location/
.htaccess syntax:

RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]
Redirect URLs with query parameters (files placed in subdirectory)

Original URL:

http://www.example.com/sub-dir/index.php?id=1
Desired destination URL:

http://www.example.com/path-to-new-location/
.htaccess syntax:

RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]
Redirect one clean URL to a new clean URL

Original URL:

http://www.example.com/old-page/
Desired destination URL:
http://www.example.com/new-page/
.htaccess syntax:

RewriteEngine On
RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L]
Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level

Original URL:

http://www.example.com/index.php?id=100
Desired destination URL:

http://www.example.com/100/
.htaccess syntax:

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory

Original URL:
http://www.example.com/index.php?category=fish
Desired destination URL:
http://www.example.com/category/fish/
.htaccess syntax:

RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]
Domain change – redirect all incoming request from old to new domain (retain path)

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]
If you do not want to pass the path in the request to the new domain, change the last row to:

RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L]

#From blog.oldsite.com -> www.somewhere.com/blog/
retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC]

apache_conf 将域重定向到子域

.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite\.com$ [NC]
RewriteRule ^(.*)$ https://subdomain.mysite.com/ [L,R=302]