【问题标题】:Alter URL using htaccess使用 htaccess 更改 URL
【发布时间】:2018-06-06 14:29:44
【问题描述】:

需要将CAE/index.php/ 插入URL 的htaccess 重定向代码。 重定向代码应检查此 sn-p 是否存在于 URL 中。只有当它不存在时,才应该插入代码。

例如。 以下网址

http://localhost/dataPage

应该重定向如下:

http://localhost/EWQ/index.php/dataPage

【问题讨论】:

    标签: regex .htaccess url redirect url-rewriting


    【解决方案1】:

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

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^((?!EWQ/index\.php/).*)$ EWQ/index.php/$1 [L,NC]
    

    【讨论】:

    • 您尝试的 URL 是什么,这个 htaccess 位于何处?
    • localhost/dataPage 是尝试的 URL。 htaccess 位于 index.php 所在网站的根文件夹中。
    • 当您打开http://localhost/dataPage 时遇到了什么错误?这个 .htaccess 中还有更多规则吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-16
    • 2012-07-31
    • 2017-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多