本文介绍了我如何获得的.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从通配符子域名页面重定向到通配符子域文件夹
发布评论