htaccess 动态 URL

发布于 2024-09-11 04:27:26 字数 550 浏览 3 评论 0原文

我正在使用带插件的 Wordpress,它目前正在制作如下网址: http://www.example.com/?name=the-office

我想将所有类似的网址重定向到 http://www.example.com/name/the-office

Current htaccess:

    # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

我尝试了一些方法,但似乎没有任何效果,也许我需要将 RewriteCond 放在 IfModule 中?不确定,htaccess 对我来说很陌生。提前致谢。

I'm using Wordpress with a plugin and it's currently making urls like this: http://www.example.com/?name=the-office

I would like to redirect all similar urls to http://www.example.com/name/the-office

Current htaccess:

    # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I tried a few things and nothing seemed to work, maybe I'm need to place the RewriteCond in the IfModule? Not sure, htaccess is foreign to me. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有伤那来痛 2024-09-18 04:27:26

如果您想要一个更容易完成的解决方法 - 只需登录到您的 WordPress 管理面板,转到设置,然后转到永久链接,然后您可以选择链接的外观。选择最后一个选项(帖子名称)仅获取网址中的帖子名称。

If you'd like a workaround that is much easier to accomplish - simply login to your wordpress admin panel, go to settings, then permalinks and there you can select how your links will look like. Select the last option (Post name) to get only post names in the urls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文