0

我需要通过以下URL 重写来制作SEO友好的 URL :

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文件放在哪里?在根目录还是子文件夹中?

4

1 回答 1

0

这应该可以工作:

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

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

于 2012-04-14T10:01:56.447 回答