当人们访问我的域名时,它会使用php代码重定向到http://www.mydomain.com/en/index.php。
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RedirectPermanent /pages/abc-123.html http://www.mydomain.com/en/page-a1/abc.php
将人们从非www重定向到www,
用户仍然可以通过输入http://mydomain.com/en/page-a1/abc.php和http://www.mydomain.com/en/page-a1/abc.php URL来访问
有没有人知道的方法完全重定向到http://www.mydomain.com/en/page-a1/abc.php,即使用户键入http://www.mydomain.com/en/page-a1/abc.php,并禁止访问没有www的网址。
6条答案
按热度按时间hgtggwj01#
在php中
ie3xauqp2#
正常工作
fivyi3re3#
我不知道如何通过.htaccess来实现,但我自己在
config.php
中使用PHP代码来实现,config.php
为每个文件加载。编辑:@genesis,你是对的,我忘记了https
变化
到
5n0oy7gb4#
在
RewriteCond
之前添加RewriteEngine On
以启用重写规则:如果你有https:
cuxqih215#
我认为你想重定向用户而不是重写URL,在这种情况下使用
Redirect
或'RedirectMatch'指令。http://httpd.apache.org/docs/2.3/rewrite/remapping.html#old-to-new-extern92vpleto6#