【问题标题】:how to redirect php to html with hyphen in url如何在url中使用连字符将php重定向到html
【发布时间】:2019-08-29 17:56:59
【问题描述】:

我想重定向我的网址,其中包含带有 php 扩展名的下划线,例如 app_development_company.phpapp-development-company.html.htaccess 文件中。

看看我的 htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*\.js) gzip.php?type=js&file=$1
    RewriteRule ^(.*\.css) gzip.php?type=css&file=$1
    #RewriteBase   /

    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    #RewriteRule    ^index\.html$       index.php   [L]
    RewriteRule    ^/$      index.php   [L]
    RewriteRule    ^iphone-app-development\.html$       iphone_development.php  [L]
    RewriteRule    ^mobile-app-development-jaipur\.html$    mobile-app-development-jaipur.php   [L]
    RewriteRule    ^android-app-development\.html$      android_app_development.php     [L]

    RewriteRule    ^404\.html$      404.php     [L]
    ErrorDocument  404 https://wedigtech.com/404.html
</IfModule>

请帮我解决这个问题。

在此感谢您

【问题讨论】:

  • 所以你想将任何/foo-bar-baz-abcd.html重写为/foo_bar_baz_abcd.php

标签: php html apache .htaccess mod-rewrite


【解决方案1】:

使用以下代码进行重定向

RewriteEngine On
RewriteBase /
RewriteRule index\.html index.php [NC,R]

也可以参考下面的链接

https://css-tricks.com/how-to-redirect-indexhtml-to-indexphp/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    • 2015-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    相关资源
    最近更新 更多