user2935236
user2935236

Reputation: 189

Need to correct htaccess to restrict some folder

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]

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

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.

Upvotes: 1

Views: 57

Answers (1)

anubhava
anubhava

Reputation: 785098

Just below RewriteBase /apnaujjain line add this line:

RewriteEngine On
RewriteBase /apnaujjain/

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

# rest of your existing rules

Upvotes: 1

Related Questions