创建使用的.htaccess干净的网址干净、网址、htaccess

2023-09-02 00:57:04 作者:含恨不如意′

Helllo我有这个页面上,有一个动态表,该表包括一个记录的记录,我已显示该记录成功,但在点击我的动态表中的任何一项它给了我一个丑陋的网址

Helllo i have this page that has a dynamic table that consist of records of a recordset, i have displayed this records successfully, but on click on any item on my dynamic table it gives me an ugly url

本地主机/短信/ mem.php?ID = 8

localhost/sms/mem.php?id=8"

但我想这个URL转换为这样的事情

but i want to convert this url to something like this

本地主机/短信/ MEM / 8

localhost/sms/mem/8

我已阅读并试图创造干净的网址,  但dosent似乎我的网址转换为自动清洁的URL,这是西隧我使用试图

i have read and tried to create clean urls, but it dosent seem to convert my url to a clean url automatically, this is wht i have tried using

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ mem.php?id=$1
RewriteRule ^([a-zA-Z0-9]+)/$ mem.php?id=$1

我在干什么不对劲,导致其在网上解释的方式似乎pretty的简单

am i doin something wrong, cause the way its been explained online it seems pretty simple

推荐答案

您现有的规则之前,将本

Place this before your existing rule:

RewriteEngine On
RewriteBase /sms/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

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

RewriteRule ^mem/([a-zA-Z0-9]+)/?$ mem.php?id=$1 [L,QSA,NC]

这应该是 /sms/.htaccess 文件的地方