Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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/9/security/4.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
Apache HTTP到HTTPS mod_使用干净的URL重写_Apache_Security_Mod Rewrite_Https_Clean Urls - Fatal编程技术网

Apache HTTP到HTTPS mod_使用干净的URL重写

Apache HTTP到HTTPS mod_使用干净的URL重写,apache,security,mod-rewrite,https,clean-urls,Apache,Security,Mod Rewrite,Https,Clean Urls,我在Ubuntu 14.04 LTS上使用Apache 2.4.7。我想能够重定向这样的网址 mysite.com/privacy 到 新的URL将是安全的,并在保持URL干净的同时返回privacy.html 我目前正在编辑/etc/apache2/sites available/000-default.conf,以下是我目前掌握的内容 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOS

我在Ubuntu 14.04 LTS上使用Apache 2.4.7。我想能够重定向这样的网址

mysite.com/privacy

新的URL将是安全的,并在保持URL干净的同时返回privacy.html

我目前正在编辑/etc/apache2/sites available/000-default.conf,以下是我目前掌握的内容

RewriteEngine On
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]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule !.*\.html$ %{REQUEST_URI}.html [L]

我已经能够将HTTP重定向到HTTPS,包括添加www或使用干净的URL访问privacy.html,但在执行这两项操作时,我找不到资源。任何帮助都将不胜感激。

不要使用“重写”,请看以下内容:谢谢,这很有效!我在端口80 VirtualHost中使用了重定向永久,并在端口443 VirtualHost中添加了干净的URL重写规则。