我如何获得的.htaccess从通配符子域名页面重定向到通配符子域文件夹

编程入门 行业动态 更新时间:2024-10-27 20:38:20
本文介绍了我如何获得的.htaccess从通配符子域名页面重定向到通配符子域文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要重定向

*.domain.co.uk/services.php

*.domain.co.uk/services

其中, * 是通配符域。

在理想情况下,htaccess的应该阅读服务页面(因为我有一个以上的),并重定向到相同的服务文件夹。

Ideally, htaccess should read the services page (as I have more than one) and redirect to the same services folder.

这是因为我已经改变了我的PHP页面文件夹/的index.php 。

This is because I have changed my PHP pages to folder/index.php.

推荐答案

这添加到htaccess文件在你的文档根目录(S):

Add this to the htaccess file in your document root(s):

RedirectMatch 301 ^/([^/]+)\.php$ /$1/

您将最有可能需要一个斜线,因为如果它是你重定向到一个目录,mod_dir将重定向的再次为了增加结尾的斜线。

You'll most likely need that trailing slash because if it's redirecting you to a directory, mod_dir will redirect again in order to add the trailing slash.

编辑:

要排除,你必须使用mod_rewrite:

To exclude, you'll have to use mod_rewrite:

RewriteEngine On RewriteCond %{REQUEST_URI} !index\.php RewriteRule ^/?([^/]+)\.php$ /$1/ [L,R=301]

更多推荐

我如何获得的.htaccess从通配符子域名页面重定向到通配符子域文件夹

本文发布于:2023-11-01 20:46:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   如何获得   文件夹   重定向   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!