[英]Redirect all traffic to one sub-directory with httpd.conf
I have a httpd.conf
file with many domains configured on my server. 我有一个
httpd.conf
文件,其中在服务器上配置了许多域。 I need to redirect an old directory on just one website to a new directory. 我需要将一个网站上的旧目录重定向到新目录。
Basically, when a user accesses any page in the dir domain.com.au/store
, I want them to be redirected to domain.com.au/shop
. 基本上,当用户访问dir
domain.com.au/store
中的任何页面时,我希望将它们重定向到domain.com.au/shop
。
I don't want the redirect to include the old webpath, so any old URL needs to redirect only to the domain.com.au/shop
page, not to /shop/old_webpath
. 我不希望重定向包含旧的Web路径,因此任何旧URL仅需要重定向到
domain.com.au/shop
页面,而不是/shop/old_webpath
。
I've tried many redirect entries from around the web, none seem to work correctly, as they all redirect to /shop/old_webpath
, not just /shop
. 我已经尝试了许多来自网络的重定向条目,但似乎都无法正常工作,因为它们全部都重定向到
/shop/old_webpath
,而不仅仅是/shop
。
Can any apache minds help? apache的思想可以帮助吗?
Try this in .htaccess
file: 在
.htaccess
文件中尝试以下操作:
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^store/(.*)$ \/shop
</IfModule>
Update for virtual host in apache configuration for domain.com.au
: 在Apache配置中为
domain.com.au
更新虚拟主机:
<VirtualHost *:80>
# ...
<Directory "[your_path]">
# ...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^domain\.com\.au$ [NC]
RewriteRule ^store/(.*)$ \/shop
</Directory>
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.