使用共享SSL URL中的子文件夹如何重写 [英] How to rewrite within subfolder using shared ssl url

查看:108
本文介绍了使用共享SSL URL中的子文件夹如何重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重写URL上使用共享SSL托管帐户的附加域。
网址有问题的一个例子是:

I'm trying to rewrite a url for an addon domain on a hosting account that uses shared ssl.
An example of the url in question is:

secure123.hostdomain.com/~username/subfolder/Page

我想这个网址重定向到:

I would like this url to redirect to:

secure123.hostdomain.com/~username/subfolder/pagename.php

不是不管什么我读或尝试我似乎无法获得htaccess的正确重定向。

Not matter what I read or try I cannot seem to get the htaccess to redirect correctly.

我一直在尝试多次尝试:

I have been trying multiple attempts:

RewriteRule ^Page$ pagename.php [NC,L]
RewriteRule ^Page$ ~username/subfolder/pagename.php [NC,L]
RewriteRule ^~username/subfolder/Page$ ~username/subfolder/pagename.php [NC,L]

我甚至用了一个建议尝试

I even tried using a suggestion of

RewriteRule ^(^/+)/(^/+)/Page$ ~username/subfolder/pagename.php [NC,L]

没有运气,我至今。

你会正确重写规则是这样?

What would the correct rewriterule be for this?

推荐答案

我觉得你是想这样的事情。

I think you are wanting something like this.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)$ /$1/$2/$3.php [R,NC,L]

这将允许您使用

secure123.hostdomain.com/~username/subfolder/Page

,然后它会重定向到这个

and then it will redirect to this

secure123.hostdomain.com/~username/subfolder/Page.php

请注意,这将是一个外部重定向使URL会在地址栏更改。如果您不想更改URL,这是一个内部重定向,只是删除研究的最后一行,所以它读取 [NC, L]

Note that it will be an external redirect so the URL will change in the address bar. If you don't want the URL to change and it be an internal redirect, just remove the R on the last line so it reads [NC,L].

希望有所帮助。

这篇关于使用共享SSL URL中的子文件夹如何重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆