gpt4 book ai didi

.htaccess - 通过 URL 重写创建 SEO 友好的 URL

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:46:35 26 4
gpt4 key购买 nike

我需要制作 SEO带有 URL rewriting 的友好 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 放在哪里?文件?在根文件夹还是子文件夹?

最佳答案

这应该可行:

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

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

关于.htaccess - 通过 URL 重写创建 SEO 友好的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10151974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com