.htaccess - 使用 htaccess 转换 url ...删除和添加单词

标签 .htaccess url-rewriting seo

这是页面的url。 <强> http://www.themobilesapp.com/phones.php?title=Apple

我想对这个 URL 做一点改动。 我想要这样的网址。 <强> http://www.themobilesapp.com/phones/Apple

为此,我的 htaccess 代码是这样的。

RewriteEngine On
RewriteRule ^phones/([A-Za-z0-9]+)?$ phones.php?title=$1

但这对我不起作用。

最佳答案

您想将 http://www.themobilesapp.com/phones/Apple 重定向到 http://www.themobilesapp.com/phones.php?title=Apple.

以下 .htaccess 规则使它发生:

RewriteEngine On
RewriteRule ^phones/(.*)$ /phones.php?title=$1 [R=301,L,QSA]

我用 htaccess.mwl.be 测试了这段代码.

关于.htaccess - 使用 htaccess 转换 url ...删除和添加单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42465488/

相关文章:

apache - 防止 googlebot 索引 robots.txt 和 .htaccess 中的文件类型

php - .htaccess:RewriteBase 采用一个参数,即每个目录上下文的基本 URL

apache - 将 RewriteRules 合并到 .htaccess 中,以便忽略特定查询参数

ASP.NET URL 重写;这可能吗?

.htaccess - 如何使用 htaccess 用 hash # 重写 url

svn - 我怎样才能说服 mod_rewrite 远离我的 Subversion 存储库?

file - 重写 WWW 和文件扩展名?

seo - 搜索词用斜线分隔(作为路径段)还是用破折号分隔?

html - 具有操作 =""的表单

sharepoint-2010 - 我可以使用 SharePoint 2010 for Internet Sites 制作对 SEO 友好的网页吗?