简体   繁体   English

用.htaccess重写的URL在xampp上不起作用

[英]URL rewrite with .htaccess is not working at xampp

My current url is 我目前的网址是

  • http://localhost/b2b/post.php?postid=15 http://localhost/b2b/post.php?postid = 15

I want to display my url as 我想显示我的网址为

  • http://localhost/b2b/post/15 ,or http:// localhost / b2b / post / 15,或
  • http://localhost/b2b/[title_of_postid_number] http:// localhost / b2b / [title_of_postid_number]

I use the following code but it not woking 我使用以下代码,但无法正常工作

RewriteEngine On
RewriteRule ^post/(.*) /post.php?postid=$1

I think it's because the rewrite engine is look for: 我认为这是因为重写引擎正在寻找:

  • [http://localhost/post/*] [http:// localhost / post / *]

Instead of looking for: 而不是寻找:

  • [http://localhost/b2b/post/*] [http:// localhost / b2b / post / *]

Try adding: 尝试添加:

RewriteBase /b2b/

before the RewriteRule. 在RewriteRule之前。

Remove the / before post.php? post.php?之前删除/ post.php? . So your code should be: 因此,您的代码应为:

RewriteEngine On
RewriteRule ^post/(.*) post.php?postid=$1

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

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