注意:,我在this question下尝试过这些建议,但是它们要么不起作用,要么给我一个无限的重定向循环错误。
我的.htaccess文件中有以下内容:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Rewrite old links to new
Redirect 301 /howitworks.php /how-it-works
Redirect 301 /testimonials.php /testimonials
Redirect 301 /contact_us.php /customer-service
Redirect 301 /affiliates.php /affiliates
Redirect 301 /account.php /customer/account
Redirect 301 /shopping_cart.php /checkout/cart
Redirect 301 /products.php /starter-kits
Redirect 301 /login.php /customer/account/login
# Force to Admin if trying to access admin
RewriteCond %{HTTP_HOST} www\.example\.com [NC]
RewriteCond %{REQUEST_URI} admin [NC]
RewriteRule ^(.*)$ https://admin.example.com/index.php/admin [R=301,L,QSA]
# Compress, Combine and Cache Javascript/CSS
RewriteRule ^(index.php/)?minify/([^/]+)(/.*.(js|css))$ lib/minify/m.php?f=$3&d=$2
# Always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
# Never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !server-status
# Rewrite everything else to index.php
RewriteRule .* index.php [L]
# Force www in url and non-example domains to example
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^ww2\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^qa\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^uat\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^local\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^admin\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L,QSA]
</IfModule>我需要一次重写,它将完成以下操作:
重写:http://subdomain.example.com/ to http://subdomain.example.com/page
我也希望这样隐藏/page (/将表现为它是/page),但这不是必要的要求。另外,我希望它能与HTTP或HTTPS一起工作。
任何帮助都是非常感谢的,因为我已经为此挣扎了几个小时。
发布于 2011-07-11 05:18:26
根路径的正确重定向只需:
RewriteEngine On
RewriteRule ^/$ /page [R]要强制在一个子域上执行此操作(如果重写块位于虚拟主机定义中,则几乎不会发生这种情况):
RewriteEngine on
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteRule ^/$ /page [R]发布于 2012-12-30 21:09:31
复制已删除的回复:
在您的文档根的htaccess中,只需:
RewriteEngine on
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteRule ^$ /page发布于 2016-11-07 16:56:03
您有两个选项可以将根重写到另一条路径,
DirectoryIndex anotherPath
RewriteEngine on RewriteRule ^/?$ /anotherPath L
您可以使用上述选项之一将example.com/内部重定向到example.com/anotherPath。
参考文献:
https://stackoverflow.com/questions/2766443
复制相似问题