简体   繁体   English

在PHP中使用.htaccess重写URL无法正常工作

[英]Rewrite url using .htaccess in php not working

I want rewrite below url 我想改写下面的网址

http://www.example.com/page.php?n=About%2BUs&id=F534Z531G538 http://www.example.com/page.php?n=关于%2BUs&id = F534Z531G538

to

http://www.example.com/about-us http://www.example.com/about-us

using .htaccess file. 使用.htaccess文件。 i have tried below code in my .htaccess 我已经尝试过我的.htaccess中的以下代码

Options +FollowSymlinks
RewriteEngine on
rewriterule ^page.php?n=About%2BUs&id=F534Z531G538(.*)$ http://www.example.com/about-us$1 [r=301,nc]

but this is not working and also id is randomly generate. 但这不起作用,并且id是随机生成的。

anyone can help me ? 有人可以帮助我吗?

try this 尝试这个

 RewriteRule ^about-us/([a-zA-Z0-9]+)$ page.php?id=$1

for http://www.example.com/about-us/f14dfa 对于http://www.example.com/about-us/f14dfa

for http://www.example.com/about-us 对于http://www.example.com/about-us

 RewriteRule ^about-us$ page.php

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

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