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
Regex 动态域访问重定向_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex 动态域访问重定向

Regex 动态域访问重定向,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我在htaccess文件中创建了www域重定向: RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L] ErrorDocument 404 / 所有的作品,但我不想每次手动输入域名。 如何将example.com更改为动态域名? 有人能帮我吗?你可以使用: ErrorDocument 404 / RewriteEn

我在htaccess文件中创建了www域重定向:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
ErrorDocument 404 /
所有的作品,但我不想每次手动输入域名。 如何将example.com更改为动态域名? 有人能帮我吗?

你可以使用:

ErrorDocument 404 /
RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]