【问题标题】:How to force the /~username on URLs for cPanel temporary URLs如何在 cPanel 临时 URL 的 URL 上强制使用 /~username
【发布时间】:2013-10-28 11:25:27
【问题描述】:

在 cPanel 临时 URL 上安装一些东西,例如:ip.add.ress/~username

代码中的 CSS、JS 文件和 href 等的链接...从 URL 中删除 /~用户名。

有没有办法使用 .htaccess 文件将用户名强制输入 URL?

例子

/my-includes/css.css

/my-includes/js.js

获取:

/~用户名/my-includes/css.css

/~用户名/my-includes/js.js

谢谢

【问题讨论】:

    标签: php .htaccess cpanel


    【解决方案1】:

    是的,可以在您的 DOCUMENT_ROOT/.htaccess 文件中使用此代码:

    # Turn mod_rewrite on
    RewriteEngine On
    
    RewriteRule ^(my-includes/.+)$ /~username/$1 [L,NC,NE,R]
    

    参考:Apache mod_rewrite Introduction

    【讨论】:

      【解决方案2】:

      如果您是服务器所有者,您可以通过 WHM Home »Security Center »Apache mod_userdir Tweak 执行此操作,您可以在其中启用或禁用安全功能以禁用 mod_userdir。由于这种方法,这种配置可能会令人困惑。您需要为服务器上的所有用户禁用 Mod_userdir 保护,以便能够使用 ~username

      您也可以打开此保护禁用 mod_userdir,然后将特定用户排除在此保护之外。

      请看:http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/TweakModuserdir

      【讨论】:

        【解决方案3】:

        这是一个老问题,但您还需要确保 PHP 处理程序是 suphp,而不是 cgi。我启用了 multiPHP 并将 PHP7 保留在 cgi 上,但也有 PHP56 但在 suphp 上。

        另外,请务必在 mod_userdir 调整中排除特定用户。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-02-24
          • 2021-04-13
          • 2015-06-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多