使用共享SSL URL中的子文件夹如何重写重写、文件夹、SSL、URL

2023-09-02 20:37:52 作者:来自软萌系の仙女

我试图重写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].

希望有所帮助。