【问题标题】:Creating SEO friendly URLs with URL rewriting使用 URL 重写创建对 SEO 友好的 URL
【发布时间】:2012-04-26 11:24:35
【问题描述】:

我需要使用URL rewriting 来制作SEO 友好网址:

http://www.myurl.com/subfolder/index.php?service=example1&location=city1

http://www.myurl.com/subfolder/cars.php?service=example1&location=city1

http://www.myurl.com/subfolder/bicycle.php?service=example1&location=city1

http://www.myurl.com/subfolder/example1/example2/index.html

http://www.myurl.com/subfolder/example1/example2/cars.html

http://www.myurl.com/subfolder/example1/example2/bicycle.html

我的 URL 重写根本不起作用,

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^index/(\w+)/?$ index.php?service=$1&location=$2
RewriteRule ^cars/(\w+)/?$ cars.php?service=$1&location=$2
RewriteRule ^bicycles/(\w+)/?$ bicycles.php?service=$1&location=$2

我应该把.htaccess 文件放在哪里?在根目录还是子文件夹中?

【问题讨论】:

标签: .htaccess mod-rewrite url-rewriting seo


【解决方案1】:

这应该可行:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /subfolder/$3.php?service=$1&location=$2 [L]

你应该把它放在根目录下。

【讨论】:

猜你喜欢
  • 2017-04-01
  • 2014-10-06
  • 1970-01-01
  • 2015-07-30
  • 2013-06-19
  • 2014-12-04
  • 2011-06-11
  • 1970-01-01
  • 2015-04-08
相关资源
最近更新 更多