大多数人似乎都在询问如何将 .htaccess 转换为 vhost.conf。我需要反过来的东西。我有一个现有的 vhost.conf 文件,看起来像这样....
ServerAlias base1.mydomain.com
ServerAlias base2.mydomain.com
ServerAlias base3.mydomain.com
ServerAlias www.mysite1.co.uk
ServerAlias www.mysite2.co.uk
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/code/
RewriteCond %{REQUEST_URI} !^/php/
RewriteCond %{REQUEST_URI} !^/php-bin/
RewriteCond %{REQUEST_URI} !^/syles/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_URI} !^/jquery/
RewriteRule ^/(.*)$ /var/www/vhosts/mydomain.com/subdomains/${lowercase:%{SERVER_NAME}}/htdocs/$1
Alias /scripts/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_0_1/scripts/"
Alias /php/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_0_1/php-bin/"
<Files ~ (\.phtml)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .phtml
Options +ExecCGI
allow from all
</Files>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
allow from all
</Files>
<Files ~ (\.php4)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php4
Options +ExecCGI
allow from all
</Files>
Alias /php-bin/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/php-bin/"
Alias /js/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/js/"
Alias /css/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/styles/"
Alias /jquery/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/jquery/"
我正在尝试将其转换为 .htaccess 文件。从顶部开始,与 serveralias 等效的 .htaccess 命令是什么?
并非
vhost.conf
中的所有内容都可以复制到 .htaccess,因为 .htaccess
. 中不允许所有指令
您可以将此代码放入您的
DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine on
RewriteCond ${HOST_NAME} [A-Z]
RewriteCond %{REQUEST_URI} !^/(images|code|php|php-bin|styles|js|jquery)/
RewriteRule ^(.*)$ http://${lowercase:%{HOST_NAME}}/$1 [L,R]
<Files ~ (\.phtml)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .phtml
Options +ExecCGI
allow from all
</Files>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
allow from all
</Files>
<Files ~ (\.php4)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php4
Options +ExecCGI
allow from all
</Files>
我无法将下面给出的代码转换为 .htaccess 结构。你能帮忙吗?
server {
listen 8080;
listen [::]:8080;
server_name domain.com www1.domain.com;
{{root}}
try_files $uri $uri/ /index.php?$args;
index index.php index.html;
location /status {
stub_status on;
access_log off;
log_not_found off;
}
location ~* ^/hlspnl/(.*)/ {
try_files $uri $uri/ /hlspnl/index.php?$args;
}
location ~* ^/player/video/(.*) {
try_files $uri $uri/ /player/player.php?data=$1;
}
location ~* ^/(.*)/master.txt {
try_files $uri $uri/ /player/loadstream.php?path=$1&$args;
}
location ~* ^/m3/(.*) {
try_files $uri $uri/ /player/loadm3u8.php?path=$1;
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}
if (-f $request_filename) {
break;
}
}
server {
listen 80;
listen [::]:80;
server_name domain.com www1.domain.com;
{{root}}
{{nginx_access_log}}
{{nginx_error_log}}
{{settings}}
location / {
{{varnish_proxy_pass}}
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Varnish;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}
if (-f $request_filename) {
break;
}
}