热搜:NVER 

Appache RewriteRule有关问题

2024-04-26 09:13:01
 Appache RewriteRule有关问题

Appache RewriteRule问题
我想在地址栏里输入 http://web/cms/user_detail/74/41245/
然后将其重定向到 http://web/cms/user_detail.php?id=74&contents_id=41245
可是RewriteRule没起作用,报404错误

Not Found
The requested URL /cms/user_detail/74/41254/ was not found on this server.

这是为什么呢?

httpd.conf的相关配置如下,请问还缺了什么配置吗?


---------------------------------------



LoadModule rewrite_module modules/mod_rewrite.so


  Options FollowSymLinks
  AllowOverride All
  Order deny,allow
  Deny from all



  Options Indexes FollowSymLinks
  AllowOverride All 
  Order allow,deny
  Allow from all




  ServerAdmin mike@sina.com
  DocumentRoot D:\webroot
  DirectoryIndex index.html index.htm index.php
  ServerName web  
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/user_detail/([0-9]+)/([0-9]+)/?$
RewriteRule ^(.*)$ /user_detail.php?id=%1&contents_id=%2
 


------解决方案--------------------
没有找到页面,你是不是用的框架,如果是的话看一下路由正则匹配
------解决方案--------------------
首先,把你的网站根目录定位成cms,要不就不要用.conf文件,在cms文件夹中用.htaccess

然后再试试这个(删除你原来的cond和rule):

XML code
RewriteRule /user_detail/([0-9]+)/([0-9]+)$ /user_detail.php?id=%1&contents_id=%2 [QSA,L]