2011-12-28 119 views
0

基本上所有我想做的事情是这样的:在.htaccess文件中的mod_rewrite缩短URL

我有一个网址为PDF文件,在此位置服务器上:

http://chudz.co.uk/philaletheians.co.uk/Study%20notes/Atlantean%20Realities/Atlantis'%20study%20-%20Appendices%20and%20Notes.pdf 

现在我想删除URL的这一部分:

/Study%20notes/Atlantean%20Realities/ 

这是我在我的htaccess的文件已经做了,它不工作:

Options +FollowSymlinks 
RewriteEngine On 
RewriteRule ^/ /Study%20notes/Atlantean%20Realities/ 

我是新来的!正如你可能会看到上面:)我必须保持服务器上的目录布局,因此它是我唯一的选择是使用mod_rewrite也许?

回答

0

尝试添加以下到.htaccess文件在你的域的根文件夹

Options +FollowSymlinks 
RewriteEngine On 
RewriteBase/

#if request does not already start with /Study notes/Atlantean Realities/ 
RewriteCond %{REQUEST_URI} !^/Study\ notes/Atlantean\ Realities/ [NC] 
#rewrite it to the /Study%20notes/Atlantean%20Realities/ directory 
RewriteRule (.*) /Study\ notes/Atlantean\ Realities/$1 [L] 
+0

你好,我已经尝试了上面,但我刚刚得到内部服务器错误500 – Chudz 2011-12-29 00:25:43

+0

我上面编辑,以逃避的空间目录和网址,如果可以的话,你应该删除它 – 2011-12-29 03:00:45