Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php joomla htaccess 2步骤重定向_Php_.htaccess_Url_Redirect_Joomla - Fatal编程技术网

Php joomla htaccess 2步骤重定向

Php joomla htaccess 2步骤重定向,php,.htaccess,url,redirect,joomla,Php,.htaccess,Url,Redirect,Joomla,我最近将该网站改为HTTPS,之前该网站同时使用非www和www url版本 现在我把网站改成了HTTPS,并强制从非www重定向到www 对于旧的http+www URL,一切正常,例如: 旧网址 http://www.example.com/about-us.html http://example.com/about-us.html OR https://example.com/about-us.html 新网址 https://www.example.com/about-us.html

我最近将该网站改为HTTPS,之前该网站同时使用非www和www url版本

现在我把网站改成了HTTPS,并强制从非www重定向到www

对于旧的http+www URL,一切正常,例如:

旧网址

http://www.example.com/about-us.html
http://example.com/about-us.html OR https://example.com/about-us.html
新网址

https://www.example.com/about-us.html
在这种情况下,旧url将完全重定向到新url,没有问题

但一旦旧url不是WWW,它就会重定向到HTTPS,但会重定向到index.php页面,而不是完整路径。。比如说

旧网址

http://www.example.com/about-us.html
http://example.com/about-us.html OR https://example.com/about-us.html
此文件的重定向url将为

https://www.example.com/ INSTEAD OF **https://www.example.com/about-us.html**
这是我写的htaccess,我想不出更多的了。。有人能帮忙吗。谢谢

php_flag eaccelerator.enable 1
php_flag eaccelerator.optimizer 1

Options +FollowSymLinks

RewriteEngine On

# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]

# RewriteBase /

# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTPS:Authorization}]
RewriteCond %{HTTP_HOST} ^ip29\.216-86-153\.static\.steadfast\.net$ [NC]
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^216\.86\.153\.29
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]

RewriteRule ^alcatel-7404.html(.*)$ https://www.example.com/alcatel-lucent/alcatel-7404.html$1 [r=301,nc]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

RewriteCond %{HTTPS} OFF
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
php\u标志eaccelerator.enable 1
php_标志eaccelerator.optimizer 1
选项+FollowSymLinks
重新启动发动机
#阻止任何试图在URL中对数据进行base64_编码的脚本。
RewriteCond%{QUERY\u STRING}base64\u encode[^(]*\([^)]*\)[或]
#阻止在URL中包含标记的任何脚本。
重写cond%{QUERY_STRING}(|%3E)[NC,或]
#阻止任何试图通过URL设置PHP全局变量的脚本。
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
#阻止任何试图通过URL修改_请求变量的脚本。
重写条件%{QUERY\u STRING}\u请求(|\[|\%[0-9A-Z]{0,2})
#返回403禁止标题并显示根主页的内容
重写规则。*index.php[F]
#重写基/
#如果请求的路径和文件不是/index.php,则
#尚未在内部重写为index.php脚本
重写cond%{REQUEST_URI}!^/index\.php
#请求的路径和文件与物理文件不直接匹配
重写cond%{REQUEST_FILENAME}!-f
#请求的路径和文件与物理文件夹不直接匹配
重写cond%{REQUEST_FILENAME}!-d
#在内部将请求重写为index.php脚本
重写规则。*index.php[L]
重写规则。*-[E=HTTP\U授权:%{HTTPS:AUTHORIZATION}]
RewriteCond%{HTTP_HOST}^ip29\.216-86-153\.static\.steadfast\.net$[NC]
重写规则^(.*)$https://www.example.com$1[R=301,L]
重写cond%{HTTP_HOST}^216\.86\.153\.29
重写规则^(.*)$https://www.example.com$1[R=301,L]
重写规则^alcatel-7404.html(.*)$https://www.example.com/alcatel-lucent/alcatel-7404.html$1[r=301,北卡罗来纳州]
RewriteCond%{HTTP_HOST}^example.com[NC]
重写规则^(.*)$https://www.example.com/$1[L,R=301]
重写条件%{HTTPS}关闭
重写规则。*https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写COND%{HTTP_HOST}!^www\。
重写规则。*https://www.%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
希望有人能帮忙。谢谢将http重定向到,您可以使用

RewriteCond %{HTTPS} OFF [NC]
RewriteCond www.%{HTTP_HOST} ^(?:www\.)?(www\..+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R]

从htaccess中删除最后2条规则,在“RewriteEngine on”行下面添加此命令,并清除浏览器缓存。是的!!!成功了!))我对代码所做的唯一更改是添加了https而不是http!非常感谢!!