繁体   English   中英

htaccess重定向查询未加载页面

[英]htaccess redirect query is not loading page

我无法使它正常工作。 我想要

http://localhost/test/post.php?id=15 

显示

http://localhost/test/post/15

我的尝试加载了一个没有CSS的页面,并向我显示了我的客户404错误页面

Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
ErrorDocument 404 /errors/404.php

RewriteCond %{QUERY_STRING} ^id=(.+)$ [NC]
RewriteRule ^post\.php post/%1? [R,L]

请帮帮我!

为此,您将需要%{THE_REQUEST}变量。 THE_REQUEST变量表示Apache从您的浏览器收到的原始请求,在执行某些重写规则后不会被覆盖。 此变量的示例值为GET /index.php?id=123 HTTP/1.1

您的代码将是:

ErrorDocument 404 /errors/404.php
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/

RewriteCond %{THE_REQUEST} /post\.php\?id=([^\s&]+) [NC]
RewriteRule ^ post/%1? [R=302,L]

RewriteRule ^post/([^/.]+)/?$ post.php?id=$1 [L,QSA,NC]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM