duankuan5319 2017-06-21 19:20
浏览 32
已采纳

本地主机上的RewriteRule

localhost, xampp, win 7
site root folder is s02, so all relevant files, including .htaccess is under this folder.

links like this work fine:
http://localhost/news/s02/view.php?art=160915142500&title=blue-sky

I want the following computed url
http://localhost/articles/160915142500/blue-sky

.htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^articles/([0-9]+)/([a-zA-Z-_]*)$ view.php?art=$1&title=$2 [NC,L]

result - error 404

httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so - uncommented
AllowOverride All

.htaccess (test) - this works:

RewriteEngine on
RewriteRule ^ http://example.com/? [L,R]  

phpinfo();
mod_rewrite is under Loaded Modules

Any help?

  • 写回答

2条回答 默认 最新

  • douyuan4357 2017-06-22 06:42
    关注

    Try with below rule, we are telling apache that incoming uri is not a file or directory.

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^articles/([0-9]+)/([a-zA-Z-_]*)$ /news/s02/view.php?art=$1&title=$2 [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题