-1

我需要你的帮助。

black-shoes根据您拥有的产品进​​行更改。

我在下面有那个网址

http://www.example.co.uk/detail/product.php?Sef=black-shoes

我希望它重写它

http://www.example.co.uk/detail/product.php/black-shoes

我怎么能在里面.htaccess或里面做php

更新以显示我的完整重写

RewriteEngine on
RewriteBase /

ErrorDocument 404 /test/main/pages/general/404_error.php
Options -Indexes
AuthName "main"

RewriteRule ^css/(.*)$ test/main/css/$1 [L]
RewriteRule ^framework/(.*)$ test/main/css/framework/$1 [L]
RewriteRule ^icon/(.*)$ test/main/icon/$1 [L]

RewriteRule ^img/(.*)$ test/main/img/$1 [L]
RewriteRule ^site_images/(.*)$ test/main/img/site_images/$1 [L]
RewriteRule ^js/(.*)$ test/main/js/$1 [L]

RewriteRule ^foundation/(.*)$ test/main/js/foundation/$1 [L]
RewriteRule ^vendor/(.*)$ test/main/js/vendor/$1 [L]
RewriteRule ^framework/(.*)$ test/main/js/framework/$1 [L]
RewriteRule ^footable/(.*)$ test/main/js/footable/$1 [L]

RewriteRule ^general/(.*)$ test/main/pages/general/$1 [L]
RewriteRule ^detail/(.*)$ test/main/pages/detail/$1 [L]
RewriteRule ^booking/(.*)$ test/main/pages/booking/$1 [L]
RewriteRule ^product/(.*)$ test/main/pages/product/$1 [L]

RewriteRule ^php/(.*)$ test/main/php/$1 [L]
RewriteRule ^$ test/main/pages/general/ [L]

概括

如何?Sef=从 url 剪切到/. 希望这是一个过程,如果不能,请与我分享我可以采取的任何方法。非常感谢。

4

2 回答 2

1

我对 .htaccess 有点生疏,但我相信应该这样做:

RewriteRule ^detail/product\.php/([a-z0-9-]+)/?$ detail/product.php?Sef=$1 [L]
于 2013-08-04T09:26:26.917 回答
0

查看 $_SERVER 值

print_r($_SERVER);

$_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'];

答案应该是这样的:

$url = str_replace('?'.$_SERVER['QUERY_STRING'],'/'.$_GET['Sef'],$_SERVER['REQUEST_URI']);

但是请考虑到将来除了“Sef”之外,您还会将其他变量发送到 URL 中,因此您应该首先考虑一下 url 是如何以这样的方式结束的,然后重写它。

于 2013-08-04T09:31:22.793 回答