我想创建一个.htaccess
编辑:这是我的新.htaccess文件
RewriteEngine on
Header add Access-Control-Allow-Origin "https://www.example.com, https://example.com, https://subdomain.example.com"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, X-CSRF-Token"
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^(path/to/directory/file)/([^/]+)/?$ $1.php?u=$2 [NC,L,QSA]
这是我的.htaccess文件
RewriteEngine on
Header add Access-Control-Allow-Origin "https://www.example.com, https://example.com, https://subdomain.example.com"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, X-CSRF-Token"
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ "https\:\/\/www\.example\.com\/$1" [R=301]
RewriteRule ^path/to/directory/file/([^/]*)$ path/to/directory/file.php?u=$1 [L]
此规则正常工作 :( http://example.com/file/xxxx)
RewriteRule ^file/([^/]*)$ path/to/directory/file.php?u=$1 [L]
修改:此规则正常 (http://example.com/path/to/directory/file/xxxx)
RewriteRule ^path/to/directory/file/([^/]*)$ path/to/directory/file.php?u=$1 [L]
修改:
在^之后删除第一个斜杠,使其按照in this subject的说法运行。
答案 0 :(得分:2)
用以下内容替换所有现有代码:
RewriteEngine on
Header add Access-Control-Allow-Origin "https://www.example.com, https://example.com"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, X-CSRF-Token"
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^(path/to/directory/file)/([^/]+)/?$ $1.php?u=$2 [NC,L,QSA]
确保在测试之前清除浏览器缓存。
答案 1 :(得分:1)
允许来源:
MyConnection.EnableExtensions(True)
MyConnection.LoadExtension("System.Data.SQLite.dll", "sqlite3_fts5_init") ''/// Or "SQLite.Interop.dll" as you need.
强制HTTPS:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
强制WWW:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
子域名的网址:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]