代码之家  ›  专栏  ›  技术社区  ›  LucyTurtle

.php扩展删除非Wokring

  •  0
  • LucyTurtle  · 技术社区  · 7 年前

    我正在工作的网站是www.pinkdropwellness。通用域名格式。

    目前,我正在努力删除。我的网站中URL的php扩展。

    无论我尝试谁的代码,它在我的网站上都不起作用。当我移除时。php从我的链接的href它总是会把我发送到一个没有找到的页面。

    这是我的电流。htaccess文件:

    Options +FollowSymlinks
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9-_]+)/? /$1.php
    RewriteRule ^([a-z0-9-_]+).php$ /$1/ [R]
    

    我尝试了各种不同的推荐代码,无论我尝试什么,我要么被重定向到/public\u html/link,要么被重定向到/link,这两者都是错误页面。即使我离开林克。php作为href,它显示为一个错误页面。我觉得我错过了一些简单的事情!

    编辑:

    这是我的索引。php代码:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <meta name="description" content="Pink Drop Wellness Homepage">
        <meta name="keywords" content="Pink,Drop,Wellness,Fertility,Awareness,Essential,Oils,Blog">
        <meta name="author" content="Lucy Bowe">
        <link rel="stylesheet" href="stylesheet.css">
      </head>
    
      <body>
        <img id="logo" src="/images/PinkDrop.png" alt="Pink Drop Wellness">
        <img id="tree" src="/images/Tree.png" alt="Tree" usemap="#links">
    
        <map name="links">
           <area
             shape="poly"
             name="blog"
             coords="445,105,432,123,418,132,402,132,386,136,385,156,417,168,437,185,475,208,510,197,531,167,527,141,496,106"
             href="/blog"
             alt="Blog"
            />
            <area
              shape="poly"
              name="fertilityawareness"
              coords="138,450,149,443,167,441,186,441,199,447,208,458,228,466,243,477,256,477,270,483,302,480,325,475,349,472,371,457,383,443,391,427,373,398,345,373,310,347,268,334,218,348,194,377,141,436,169"
              href="/fertilityawareness"
              alt="Fertility Awareness"
             />
             <area
               shape="poly"
               name="essentialoils"
               coords="787,490,753,498,719,523,671,553,634,566,593,541,545,487,540,432,570,407,606,403,653,420"
               href="/essentialoils"
               alt="Essential Oils"
              />
        </map>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="/scripts/jquery.imagemapster.js"></script>
        <script>
          var image = $('#tree');
    
          image.mapster({
            mapKey: 'name',
            listKey: 'name',
            clickNavigate: true,
            isSelectable: false,
            areas: [
              {
                key: "blog",
                fillColor: "5679c7",
              },
              {
                key: "essentialoils",
                fillColor: "638a69",
              },
              {
                key: "fertilityawareness",
                fillColor: "785fc2",
              }
            ]
          });
        </script>
      </body>
    </html>
    
    2 回复  |  直到 6 年前
        1
  •  2
  •   Naren Verma    7 年前

    试试这个

    它将删除。php扩展。

    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.php -f 
    RewriteRule ^(.*)$ $1.php
    

    像这样使用链接

    <a href="contact">contact</a>
    

    在Url中,它将显示为 domain.com/contact

        2
  •  1
  •   Nilesh Lathe    7 年前

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^/$    index.php    [L]
    ErrorDocument 404 http://www.akshadainfosystem.com
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    

    http://www.akshadainfosystem.com/profile 原始url http://www.akshadainfosystem.com/profile.php 只是不要添加。php扩展到您的链接,就像我做的。