2010-11-29 2 views
1

내 .htaccess 파일을 NGINX 표기법으로 변환하려고합니다.Apache .htaccess 파일에 대한 도움말

온라인 도움말을 읽었지만 여전히 어려움을 겪고 있습니다.

도움이 될만한 사람이 있습니까? 내 htaccess로는 다음과 같습니다

Options -Indexes 
Options +FollowSymLinks 

# Enable ETag 
FileETag none      

# Set expiration header 
ExpiresActive on 
ExpiresDefault A2592000 
Header append Cache-Control "public" 

# Compress some text file types 
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript application/json 

# Deactivate compression for buggy browsers 
BrowserMatch ^Mozilla/4 gzip-only-text/html 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 

# Set header information for proxies 
Header append Vary User-Agent 

######################################################## 
# Rewrite Rules 
######################################################## 

RewriteEngine on 

# Require SSL (HTTPS) on the signup page 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} ^/signup/? 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] 

# Redirect /signup/plan or /signup/plan/ -> /signup/index.php?account_type=plan 
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L] 

# Redirect /home/123 or /home/123/ -> home.php?home_id=123 
RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1 [NC,L] 

# Redirect /homes/ in case someone made a typo when it should have been /home/ 
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1 [NC,L] 

########################################################### 
# Error Handling 
########################################################### 

#ErrorDocument 400/
#ErrorDocument 401/
#ErrorDocument 403/
#ErrorDocument 404/
#ErrorDocument 500/


################################################# 
# Default Settings 
################################################# 

# hide apache server signaute on apache generated pages (e.g. 404) 
ServerSignature Off 

업데이트 : GZIP 압축을위한

는,이 작업을 나타납니다. 하지만 아직 내 HTTP Rewrites 규칙을 아직 파악하지 못했습니다.

gzip    on; 
    gzip_min_length 1000; 
    gzip_proxied  expired no-cache no-store private auth; 
    gzip_types  text/plain application/xml; 
    gzip_disable  "MSIE [1-6]\."; 

나는 다음의 nginx 규칙을 내 htaccess로 재 작성 규칙을 교체 시도하지만,이 작업을 나타나지 않습니다 2

UPDATE. 내가 뭘 잘못하고 있는거야?

# Redirect /signup/planname or /signup/planname/ -> /signup/index.php?account_type=planname 
rewrite ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 last; 

# Redirect /home/123 or /home/123/ -> home.php?home_id=123 
rewrite ^home/([0-9]+)/?$ home.php?home_id=$1 last; 

# Redirect /homes/ in case someone made a typo when it should have been /home/ 
rewrite ^homes/([0-9]+)/?$ home.php?home_id=$1 last; 

아래의 코멘트를 UPDATE 3

, 지금 다음의 nginx의 설정을 가지고 있지만 여전히 문제가 내가 documentation에서 보는 바와 같이

# gzip 
gzip    on; 
gzip_min_length 1000; 
gzip_proxied  expired no-cache no-store private auth; 
gzip_types  text/plain application/xml; 
gzip_disable  "MSIE [1-6]\."; 


# Require SSL (HTTPS) on the signup page 
# ====== THIS DOESN'T WORK AND BREAKS NGINX 
# I obviously change "example.com" to be my actual domain 
if (location /signup/) { 
    rewrite^https://www.example.com$request_uri? permanent; 
} 


# Redirect /signup/planname or /signup/planname/ -> /signup/index.php?account_type=planname 
rewrite ^signup/([A-Za-z] +)/?$ /signup/index.php?account_type=$1 last; 

# Redirect /home/123 or /home/123/ -> home.php?home_id=123 
# Also, Redirect /homes/ in case someone made a typo when it should have been /home/ 
rewrite ^/homes?/([0-9]+)/?$ /home.php?home_id=$1? last; 

답변

0

, 규칙을 데 (안 conds)는 과 같아야합니다.

A :,210
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} ^/signup/? 
RewriteRule ^(.*)$ https://www.example.com/$1 

N (자세한 내용은 here 참조)

if (location /signup) { 
    rewrite^https://pma.clinicacgm.0$request_uri? permanent; 
} 

A :

RewriteRule ^home/([0-9]+)/?$ home.php?home_id=$1 
RewriteRule ^homes/([0-9]+)/?$ home.php?home_id=$1 

N :

rewrite ^/homes?/([0-9]+)/?$ /home.php?home_id=$1? last; 
+0

감사 EIR. 그래도 질문, 난 단지 # (숫자)가 마지막 규칙에 허용합니다. "(. *)"을 사용할 때 어떤 종류의 문자도 허용하도록 규칙을 만든 것처럼 보입니다. 어떻게 만 # 수 있습니까? –

+0

죄송합니다. 위키에서 복사했습니다.'([0-9] +)'또는'([0-9] +)? '(나는 거의 테스트 할 서버가 없습니다) –

+0

As 그런데 어떤 생각이라면 왜 내 업데이트 2가 제대로 작동하지 않았기 때문에 –