如何创建点或周期

在这里htaccess的重写规则是我的网址:如何创建点或周期

example.com/profile.php?username=name.name

例子.COM/profile.php?用户名=名称

我想重写它这样

example.com/name

example.com/name.name

这里是我的.htaccess代码

RewriteEngine on 

ErrorDocument 404 /404.php

RewriteRule ^signup$ signup.php [QSA,L]

RewriteRule ^signin$ signin.php [QSA,L]

RewriteRule ^home$ home.php [QSA,L]

RewriteRule ^messages$ messages.php [QSA,L]

RewriteRule ^signout$ signout.php [QSA,L]

RewriteRule ^settings$ settings.php [QSA,L]

RewriteRule ^settings/ChangePassword$ change_password.php [QSA,L]

RewriteRule ^settings/RemoveAccount$ remove_account.php [QSA,L]

RewriteRule ^message/([0-9]+)$ show_message.php?id=$1

我已尝试添加该代码到我的.htaccess

RewriteRule ^([a-zA-Z0-9._-]+)$ profile.php?username=$1 [QSA,L] 

它工作正常使用这种类型的链接

example.com/name

但是当我试图点添加到我的链接我有一个问题,第一,这是我的代码添加点或时间段我曾尝试

RewriteRule ^([a-zA-Z0-9_\-.]+)$ profile.php?username=$1 [QSA,L] 

这个代码使纸条工作只为profile.php如果我试图去别的地方,比如邮件example.com/messages或设置example.com/settings它给了我一个404错误,我该如何解决这个问题?

回答:

我找到了答案

RewriteEngine on 

ErrorDocument 404 /404.php

RewriteRule ^signup$ signup.php [QSA,L]

RewriteRule ^signin$ signin.php [QSA,L]

RewriteRule ^home$ home.php [QSA,L]

RewriteRule ^messages$ messages.php [QSA,L]

RewriteRule ^signout$ signout.php [QSA,L]

RewriteRule ^settings$ settings.php [QSA,L]

RewriteRule ^settings/ChangePassword$ change_password.php [QSA,L]

RewriteRule ^settings/RemoveAccount$ remove_account.php [QSA,L]

RewriteRule ^message/([0-9]+)$ show_message.php?id=$1

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ([a-z0-9_\.-]+)/? profile.php?username=$1 [L,NC]

以上是 如何创建点或周期 的全部内容, 来源链接: utcz.com/qa/258382.html

回到顶部