如何进入一个特定文件夹?

时间:2016-04-06 15:31:47

标签: apache .htaccess mod-rewrite url-rewriting

我在.htaccess文件中创建了干净的网址,但之后我没有访问特定文件夹。如何访问/ folder /?

htaccess的:

Options +FollowSymLinks
RewriteEngine On

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


RewriteRule ^([a-zA-Z0-9]+)$ index.php?side=$1 [QSA]
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?side=$1 [QSA]

RewriteRule ^([a-z]+)\/([a-zA-Z0-9]+)\/?$ index.php?side=$1&id=$2 [NC]
RewriteRule ^rss/feed/([a-zA-Z0-9]+)\/?$ index.php?side=feed&id=$1 [NC]

1 个答案:

答案 0 :(得分:2)

您可以使用以下内容:

Options +FollowSymLinks
RewriteEngine On
##-if an existent dir or file is requested, serve it immideatly##    
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
########    

RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?side=$1 [QSA,L]

RewriteRule ^([a-z]+)/([a-zA-Z0-9]+)/?$ index.php?side=$1&id=$2 [NC,L]
RewriteRule ^rss/feed/([a-zA-Z0-9]+)\/?$ index.php?side=feed&id=$1 [NC,L]