需要更正的htaccess限制某些文件夹 [英] Need to correct htaccess to restrict some folder

查看:212
本文介绍了需要更正的htaccess限制某些文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的htaccess code在我的项目

I am using following htaccess code in my project

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服务也是我从Web服务调用的文件夹,网址为

Now everything is working fine except one thing I have some webservice also that I am calling from webservice folder, url is

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

现在的问题是由于htaccess的我的web服务停止工作,它重定向到错误页面,以便其不工作。我不想要应用htaccess的规则上的web服务的文件夹。请帮帮忙,先谢谢了。

Now the problem is due to htaccess my webservice stopped working, it redirecting to wrong page so its not working. I don't want to apply htaccess rule on webservice folder. Please help, thanks in advance.

推荐答案

正下方的RewriteBase / apnaujjain 行加入这一行:

RewriteEngine On
RewriteBase /apnaujjain/

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

# rest of your existing rules

这篇关于需要更正的htaccess限制某些文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆