简体   繁体   English

apache 重定向 /url1/* 到 /url1/index.html

[英]apache redirect /url1/* to /url1/index.html

I changed the context url from: domain.name/url1 to domain.name/url2我将上下文 url 从: domain.name/url1更改为domain.name/url2

I want to have a 301 redirect of all URLs from我想对来自的所有 URL 进行 301 重定向

domain.name/url1/* to the static file domain.name/url2/moved.html and show a static maintenance page domain.name/url1/*到 static 文件domain.name/url2/moved.html并显示 static维护页面

The rewrite rules should not take into account any other URLs except domain.name/url1/* for this redirect重写规则不应将此重定向考虑除domain.name/url1/*之外的任何其他 URL

url1 and url2 are subfolders in the apache directory /var/www/home/ url1url2是 apache 目录/var/www/home/中的子文件夹

The apache configuration is: apache 配置为:

Listen 9082
<VirtualHost *:9082>

ServerName domain.name

DocumentRoot "/var/www/home"

<Directory />
  Require all denied
</Directory>

<Directory "/var/www/home">
  Require all granted
  RewriteEngine on
  AllowOverride all

</Directory>

<IfModule dir_module>
  DirectoryIndex index.html index.htm index.php
</IfModule>

</VirtualHost>

You may try this code in your url1/.htaccess :您可以在url1/.htaccess中尝试此代码:

DirectoryIndex index.html
RewriteEngine On

RewriteRule ^index\.html$ - [NC,L]

RewriteRule . /url1/ [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何隐藏名称结束 url index.html - How to hidden name end url index.html 无法重定向到Apache中的其他网址 - Unable to redirect to other url in apache Apache重定向到查询的主URL - Apache redirect to main URL on Query Apache on CentOS在配置路由到“ Index.html”(大写“ I”)时出现问题 - Apache on CentOS issue configuring routing to “Index.html” (uppercase“I”) Web浏览器不在htdocs目录中显示index.html - Apache - Web browser not displaying the index.html in the htdocs directory - Apache 为什么 Apache 不允许从 index.html 中访问 web 根目录之外的文件? - Why doesn't Apache allow access to files outside the web root from within index.html? 将网址重定向到网址到www - Redirect url to url to www ubuntu 网络服务器上的 apache2 拒绝访问所提供索引以外的任何其他文件的权限。html - apache2 on ubuntu webserver rejects permission to access any other file than the delivered index.html 安装SDX麻烦org.apache.cocoon.ResourceNotFoundException:没有管道匹配的请求:index.html - Installing SDX trouble org.apache.cocoon.ResourceNotFoundException: No pipeline matched request: index.html Apache 虚拟主机不在域名处为虚拟主机“index.html”提供服务 - Apache Virtual Host isn't Serving Virtual Host 'index.html' at Domain Name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM