簡體   English   中英

.htaccess multi RewriteRule和RewriteCond幫助我將它們組合在一起

[英].htaccess multi RewriteRule and RewriteCond help me to combine them together

我需要以下.htaccess的幫助,如果可能,我需要將它們組合在一起

如果前面沒有http://www ,則它將重定向到域名前面有http://www的domainname.com.au:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domainname.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domainname.com.au$
RewriteRule ^(.*)$ "http\:\/\/www\.domainname.com.au\/$1" [R=301, OR]

並且這個應該獲得斜杠/之后在域名末尾傳遞的變量,我應該看到“ / contact”,但是PHP MVC看到這個“ /index.php?url=contact”

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

deny from 111.93.163.217

謝謝!

這兩個規則雖然不能完全相同,但無法合並,但可以將其縮短:

# Force www
RewriteCOnd %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Rewrite parameter
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [B,NE,QSA,L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM