我正试图找出一种使用.htaccess redirect,php和mysql制作html页面的方法。
我在这样的网站页面中有html链接(漂亮网址),但实际的html页面不存在。
http://localhost/Site/Directory/page.html
我想通过.htaccess将所有这样的url重定向到带有get参数的processs.php来处理并生成html页面,我正在尝试这种方式。
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
这给了我一个网址(不是很漂亮的网址)。
http://localhost/Site/process.php?dir=Directory&page=page.html
我现在可以使用php和mysql按照dir和page参数制作html页面,但问题是我的漂亮网址丢失了。
我现在再次想要在网站页面中重写这个非常漂亮的网址作为orignal url。
http://localhost/Site/Directory/page.html
为了做到这一点,我尝试过这样但是仍然没有给我如上所述的漂亮网址。
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /Site/process.php?dir=$1&page=$2 [R=301,L]
RewriteRule ^Site/$1/$2([^/.]+)/?$ [L]
请参阅并建议任何可行的方法。
感谢。
答案 0 :(得分:1)
你只需删除你的R = 301
RewriteRule ^([^ /] )/(。 .html)/Site/process.php?dir=$1&page=$2 [L]