需要更正htaccess来限制某些文件夹

时间:2015-04-08 07:05:26

标签: .htaccess

我在我的项目中使用以下htaccess代码

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /apnaujjain

#redirect localhost/apnaujjain/page.php?page_id=1&album_id=1&action=contacts to localhost/apnaujjain/1/1/contacts.html

RewriteCond %{THE_REQUEST} \s/+.+?\.php\?page_id=([^\s&]+)&album_id=([^\s&]+)&action=([^\s&]+) [NC]
RewriteRule . %1/%2/%3.html? [R=301,L]
RewriteRule ^([^/]+)/([^/]+)/([^./]+)\.html$ page.php?page_id=$1&album_id=$2&action=$3 [NC,L,QSA]

#redirect localhost/apnaujjain/page.php?page_id=1&action=contacts to localhost/apnaujjain/1/contacts.html

RewriteCond %{THE_REQUEST} \s/+.+?\.php\?page_id=([^\s&]+)&action=([^\s&]+)\s [NC]
RewriteRule . %1/%2.html? [R=301,L]
RewriteRule ^([^/]+)/([^./]+)\.html$ page.php?page_id=$1&action=$2 [NC,L,QSA]

#redirect localhost/apnaujjain/contacts.php to localhost/apnaujjain/contacts.html

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\s [NC]
RewriteRule !^admin/ /%1.html [NC,R=302,L,NE]
RewriteRule ^(.+?)\.html$ $1.php [L,NC]

#RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\s [NC]
#RewriteRule ^ /%1.html [R=302,L,NE]
#RewriteRule ^(.+?)\.html$ $1.php [L,NC]

现在一切正常,除了我还有一些web服务,我从webservice文件夹调用,url是

http://localhost/apnaujjain/webservice/gethomepagecontent1.php

现在问题是由于htaccess我的webservice停止工作,它重定向到错误的页面,所以它无法正常工作。我不想在webservice文件夹上应用htaccess规则。请提前帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

RewriteBase /apnaujjain行下方添加以下行:

RewriteEngine On
RewriteBase /apnaujjain/

# add everything for webservice/...
RewriteRule ^webservice(/.*)?$ - [L,NC]

# rest of your existing rules