我尝试了所有我在这里看到的这个网站,以重写动态网址搜索引擎优化友好的网址。
是不是因为我在本地主机中使用了它?
我试过了,但也不起作用:
RewriteCond %{THE_REQUEST} ^GET\ /index\.php/?([^ ]*)
RewriteRule ^index\.php/?(.*) /$1 [R,L]
RewriteCond $0 !^index\.php($|/)
RewriteRule .* index.php/$0 [L]
我还提到了一个在线动态url生成器,但它也不能工作。请帮帮忙。
我想重写这两个URL:
index.php?p=home
index.php?p=about me
index.php?p=contact me
发布于 2011-12-08 16:47:36
你可以使用这个:
RewriteEngine on
RewriteBase /
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1
然后在你的index.php页面上,所有的变量都可以通过$_GET'q‘访问。如果进一步使用$location=array_filter(explode('/',$_GET‘q’)),那么$location将是一个包含每个目录的数组,因此www.mysite.com/firstdir/seconddir/thirddir将把$location作为'firstdir‘,将$location1作为'seconddir’,依此类推。然后,您可以将这些内容与数据库中的url_aliases进行比较,以确定要显示的内容/模板。
这也适用于我的localhost,除非我将基本url部分从"/“更改为"/mycurrentconstructionsite/”
希望这能有所帮助!
https://stackoverflow.com/questions/8428201
复制相似问题