希望将以下内容放入我的htaccess文件中:
User visits http://mysite.com/test/test/123
User is actually visiting http://mysite.com/test/index.php?q=123
我以前见过它,但我无法理解。用户不应该看到他们正在访问第二个网址。这对SEO特别有用。任何人都可以帮我这个吗?
更新了答案代码:
Options -Multiviews
rewriterule ^test\/([a-zA-Z]+)\/([0-9]+)$ test\/index\.php?id=$3 [L]
*注意:GoDaddy托管需要选项-Multiviews才能启用mod_rewrite。*
答案 0 :(得分:1)
确保mod_rewrite已开启:
RewriteEngine on
RewriteRule ^test/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ test.php?id=$2
答案 1 :(得分:0)
双重测试
RewriteEngine On
RewriteRule ^test/test/([^/]*)$ /test/index.php?q=$1 [L]
单次测试
RewriteEngine On
RewriteRule ^test/([^/]*)$ /test/index.php?q=$1 [L]