Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex .htaccess multi-RewriteRule和RewriteCond帮助我将它们组合在一起_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Regex .htaccess multi-RewriteRule和RewriteCond帮助我将它们组合在一起

Regex .htaccess multi-RewriteRule和RewriteCond帮助我将它们组合在一起,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我需要以下方面的帮助。htaccess,如果可能,我需要将它们组合在一起 这将重定向到domainname.com.au,带有http://www在域名前面,如果前面没有http://或www: RewriteEngine on RewriteCond %{HTTP_HOST} ^domainname.com.au$ [OR] RewriteCond %{HTTP_HOST} ^www\.domainname.com.au$ RewriteRule ^(.*)$ "http\:\/\/www\

我需要以下方面的帮助。htaccess,如果可能,我需要将它们组合在一起

这将重定向到domainname.com.au,带有
http://www
在域名前面,如果前面没有
http://
www

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”


谢谢

这两条规则不能合并,因为它们完全不同,但可以缩短:

# 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]

不客气,艾迪,很高兴能帮上忙。下次见。:)
# 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]