2015-12-30 106 views
0

我知道这可能是一个简单的修复,但我无法弄清楚。mod_rewrite不使我的网址漂亮

我有我的.htaccess文件在我的根文件中称为视频文件夹。

我写了这个改写国防部:

<IfModule mod_rewrite.c> 
RewriteEngine On 


RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f 
RewriteRule ^(.*)$ $1.php [L] 

RewriteRule ^videos/([a-z0-9\-]+)$ vid.php?=$1 [L] 
</IfModule> 

出于某种原因,我的网址仍然出现这样的:?

http://localhost/fap2/videos/vid.php?id=1 

它不会取代ID = 1只1号样?vid.php/1


此外,由于该vid.php ID = 1是从的index.php A HREF,和它看起来像这样:

<a href="videos/vid.php?id=' . $tag["video_tag"] .'"> 

我的页面基于该ID。我可以以某种方式显示ID类别名称而不是数字,例如vid.php?id = 1是实际名称vid.php/category1还是基于更改href标签?

谢谢

+0

什么是你的文档根目录? FAP2? –

+0

另外,你现在的规则是否像'http:// example.com/videos/1234'这样的路径工作? –

+0

@PanamaJack是fap2 – Gianni

回答

0

试试这个

RewriteEngine on 
RewriteBase /fap2/ 
RewriteRule ^videos/([^/]+) vid.php?id=$1 [L] 
+0

这没有奏效。 – Gianni

+0

这里工作的网址http://lab.maurosala.it/fap2/videos/1 –