301 子域中的所有 aspx 文件

发布于 2024-08-31 03:24:05 字数 693 浏览 2 评论 0原文

我们刚刚为 EE 的客户重新设计了一个网站,位于 example.com(带或不带 www.)。他们的原始网站是 ASPX。他们仍然想要保留许多 ASPX 页面,因此他们的 IT 人员创建了一个子域 www2,这基本上是他们旧网站的克隆。

我需要一个 htaccess 规则来检查请求的页面是否以 .aspx 结尾,然后重定向到 www2 子域。它还应该确保请求的页面不存在

我尝试使用以下规则,但它不起作用。

RewriteRule ^http://[www\.?]example.com/(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]

我的 htaccess 文件(包括上述规则)如下所示:

RewriteEngine On

# redirect all .aspx pages to www2
RewriteRule ^http://[www\.?]example.com/(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]

# strip index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

有人有解决方案吗?

We just redesigned a site for a client in EE, located at example.com (with and without www.). Their original site is ASPX. They've still got a number of ASPX pages that they want to keep, so their IT people created a subdomain, www2, which is basically a clone of their old site.

I need an htaccess rule that will check if the requested page ends in .aspx, then redirects to the www2 subdomain. It should also make sure that the requested page doesn't exist

I tried using the following rule, but it doesn't work.

RewriteRule ^http://[www\.?]example.com/(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]

My htaccess file (including the above rule) looks like this:

RewriteEngine On

# redirect all .aspx pages to www2
RewriteRule ^http://[www\.?]example.com/(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]

# strip index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Does anyone have a solution for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵情客 2024-09-07 03:24:06

RewriteRule 指令仅执行测试URL 路径。如果要测试所请求 URL 的任何其他部分,则需要使用 RewriteCond 指令

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]

The RewriteRule directive does only test the URL path. If you want to test any other part of the requested URL, you need to use the RewriteCond directive:

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^(.*)\.aspx$ http://www2.example.com/$1 [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文