使用Htaccess文件创建SEO友好的URL [英] Creating an SEO friendly URL with Htaccess File

查看:97
本文介绍了使用Htaccess文件创建SEO友好的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置SEO友好重定向,但是需要以特定方式使用我的.htaccess.这是我的网址现在的样子:

I am trying to setup an SEO friendly redirect, but need to be using my .htaccess in a specific way. Here is what my URLs look like right now:

http://www.mywebsite.com/report/index.php?id=38678a80dfea5924

我需要更改URL,以便它们看起来像这样:

I need to change the URLs so that they look like this:

http://www.mywebsite.com/report/38678a80dfea5924

我已经阅读了几本有关创建SEO友好URL的教程,但是大多数教程都涉及对域根目录下的.htaccess进行更改.有什么方法可以做,但是只能编辑reports文件夹中的.htaccess文件?

I've read several tutorials about creating SEO friendly URLs, but most of them are referring to making changes to the .htaccess at the root of the domain. Is there any way to do this but only edit the .htaccess file that's in my reports folder?

推荐答案

如果您更改了所有链接,使它们看起来像这样:

If you've changed all of your links so that they look like this:

http://www.mywebsite.com/report/38678a80dfea5924

然后在报告"文件夹内的htaccess文件中,您只需要:

Then in the htaccess file inside the "report" folder, you just need:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?id=$1 [L,QSA]

这篇关于使用Htaccess文件创建SEO友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆