gpt4 book ai didi

apache - 使用 Mod_Rewrite 将 ROOT 重写为另一个路径

转载 作者:行者123 更新时间:2023-12-03 20:01:51 25 4
gpt4 key购买 nike

注:我已经尝试了 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/ http://subdomain.example.com/page

我也想隐藏/page (/会像/page 一样),但这不是必要的要求。另外,我希望它与 HTTP 或 HTTPS 一起使用。

非常感谢任何帮助,因为我已经为此苦苦挣扎了几个小时。

最佳答案

根路径的正确重定向很简单:

RewriteEngine On
RewriteRule ^/$ /page [R]

仅在一个子域上强制执行此操作(如果您的重写块在虚拟主机定义中,则几乎不会发生这种情况):
RewriteEngine on
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteRule ^/$ /page [R]

关于apache - 使用 Mod_Rewrite 将 ROOT 重写为另一个路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2766443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com