简体   繁体   中英

URL rewrite with .htaccess is not working at xampp

My current url is

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

I want to display my url as

  • http://localhost/b2b/post/15 ,or
  • 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/*]

Instead of looking for:

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

Try adding:

RewriteBase /b2b/

before the RewriteRule.

Remove the / before post.php? . So your code should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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