如何使用url中的连字符将php重定向到html

时间:2016-02-02 12:07:31

标签: php html apache .htaccess mod-rewrite

我想将包含下划线的网址重定向到 php 扩展名 app_development_company.php 文件中的app-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>

请帮我解决这个问题。

先谢谢你

1 个答案:

答案 0 :(得分:0)

使用以下代码进行重定向

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

另请参阅以下链接

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