返回列表 发帖

关于apache .htaccess 伪静态页路径问题

版主,各位仁兄好!

   我伪静态页的地址比指定动态页多了一个目录,导致样式读不到,图片打不开,请问怎么设置可以正常打开?
   
   伪静态页的地址: http://211.166.45.10/company/new/new_10000.html
   指定的动态地址:http://211.166.45.10/company/new.php?id=10000
   
   动态文件里的代码:
       样式: <link href="css/css.css" type="text/css" rel="stylesheet" />
       图片:<img src="images/an17.jpg" width="58" height="25" />
   
   apache httpd.conf 设置:
      LoadModule rewrite_module libexec/apache22/mod_rewrite.so

   

     Options FollowSymLinks
     AllowOverride All

     

     Alias "/company" "/usr/local/www/company/httpdocs/"
       <Directory "/usr/local/www/company/httpdocs/">
         Order Allow,Deny
         Allow from all
     </Directory>
  

     .htaccess 设置:
     rewriteengine on
     RewriteBase /company/
     RewriteRule /new/new_([0-9]{1,})\.html$ new.php?id=$1

   

    之前用的是真实的静态页,已经收录了20000多页面,所以伪静态只能用http://211.166.45.10/company/new/new_10000.html这种地址,但new.php 在根目录下,与伪静态地址差了一个目录,请问怎样设置可以正常打开样式和图片?

明白你说的意思。
我感觉你把图片和css路径都改成绝对路径比较好
或者你写个base
<base herf="http://211.166.45.10/company/"> 这样也能解决这个问题

TOP

谢谢指点,想采用第二种办法,因为第一种方法要改的内容太多
但是第二种办法,我哪用错了,new.php的代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文章信息</title>
<META name="description" content="description" />
<META name="keywords" content="keyword" />
<base herf="http://211.166.45.10/company/">
<link href="css/css.css" type="text/css" rel="stylesheet" />
</head>

<body>
  ... ...
<img src="images/001.jpg" width="58" height="25" />
  ... ...
<img src="images/048.jpg" width="58" height="25" />
  ... ...
</body>

结果还是打不开图片和css
估计原因是没有读到
http://211.166.45.10/company/css/css.css

... ...


而读的是
http://211.166.45.10/company/new/css/css.css

... ...


<base herf="http://211.166.45.10/company/"> 的正确用法是什么?谢谢

TOP

谢谢指点,想采用第二种办法,因为第一种方法要改的内容太多
但是第二种办法,我哪用错了,new.php的代码如下:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文章信息</title>
<META name="description" content="description" />
<META name="keywords" content="keyword" />
<base herf="http://211.166.45.10/company/">
<link href="css/css.css" type="text/css" rel="stylesheet" />
</head>

<body>
  ... ...
<img src="images/001.jpg" width="58" height="25" />
  ... ...
<img src="images/048.jpg" width="58" height="25" />
  ... ...
</body>


结果还是打不开图片和css
估计原因还是没有读到
http://211.166.45.10/company/css/css.css

http://211.166.45.10/company/images/001.jp g
... ...
http://211.166.45.10/company/images/0048.jp g

而读的是
http://211.166.45.10/company/zixun/css/css.css

http://211.166.45.10/company/zixun/images/001.jp g
... ...
http://211.166.45.10/company/zixun/images/0048.jp g

<base herf="http://211.166.45.10/company/"> 的正确用法是什么?谢谢

TOP

问题解决了,因为写错了一个字母 应该是href 谢谢"新程php培训"。

TOP

返回列表