2013-06-04 142 views
0

我的.htaccess文件看起来是这样的:.htacces重定向文件夹链接到index.php路由页

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

我有一些<a>链接,等于文件夹名称。例如。现在

www.mysite.com/test/scripts/ is a folder path 
<a href="/test/scripts/"> is the link 

我的问题是,如果一个链接指向一个文件夹中,我得到的403 - Forbidden错误。 如何修改我的.htaccess以将与文件夹匹配的链接重定向到index.php页面,这是一个路由页面?

回答

0

我通过addind a !解决了我的问题。这是因为如果URL不是一个文件夹,它会保留这个URL,否则它将全部重定向到index.php。

完整代码:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 
相关问题