2017-09-21 47 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 + –