2017-09-21 48 views
-1
http://localhost/shorter/?aQ3d4B 
(http://localhost/shorter/index.php?aQ3d4B) 

我想重定向url没有问号。我不能重定向URL与重写规则

so;

http://localhost/shorter/aQ3d4B 

这是行不通的。

Options +FollowSymLinks 
RewriteEngine on 

RewriteRule shorter/(.*)/ ?$1 
RewriteRule shorter/(.*) ?$1 

我必须写入.htaccess文件。

+0

你能为我写的代码? –

+0

请输入一点.htaccess知识。如果你寻找自己,你会学到更多。 您是否阅读过上述评论中的网址?它也为您提供解决方案。 – Edd

+0

我想尽一切办法,但我canttttt! –

回答

0

试试这个:

Options +FollowSymLinks 
RewriteEngine On 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 

RewriteRule ^shorter/(\w+)*$ ./shorter?id=$1 

这会给你在你的PHP中的$_GET['id']

+0

我不使用ID。我曾尝试过你的代码,但页面说,该对象不存在! 请求中的URL在服务器上找不到。如果您已手动输入网址,请观察您所写的内容并重试。 –

+0

其实,\ d +到\ w +,这就是想要的数字! – delboy1978uk

+0

不能用w + –