url构造htaccess
假设我有一个指向我的页面之一的链接,如下所示:mysite.com/48YSWD96,我需要它看起来像:mysite.com/?d=48YSWD96。我该如何实现这一目标?我可以通过修改 htaccess 文件来实现此目的吗?目前看起来像这样......
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteBase /
Lets say I have a link to one of my page that looks like: mysite.com/48YSWD96, I need it to look like: mysite.com/?d=48YSWD96. How do I achieve this? Can I achieve this by modifying my htaccess file? which currently looks like this...
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteBase /
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您只需将其附加到末尾:
要使其以相反的方式工作:
这将请求
mysite.com/?d=48YSWD96
并将 URI 更改为/48YSWD96
。本质上,无论查询字符串中的 id 等于什么。It looks like you just need to append this to the end:
For it to work the other way around:
This will take a request for
mysite.com/?d=48YSWD96
and change the URI to/48YSWD96
. Essentially, whatever the id equals in the query string.