Here is my root path folder content :
/public
/src
/script
/etc
I succesfully managed to rewrite all request to /public folder with following code :
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
My issue is that I need to access /script/script.php from browser, and it is currently returning
NOT FOUND The requested URL was not found on this server.
I tried a lot of things that I founded on stackoverflow but I am really not at ease with Apache 2 .htaccess (but need to use it on a shared hosting)
Anybody know how achieve what I want to do ? Thanks
CodePudding user response:
Have your .htaccess rules file in following manner. I have added a condition before your last RewriteRule since you want to access script.php so better put a proper condition before last rule.
Also make sure to clear your browser cache before testing your URLs.
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1? [L,NE,R=302]
RewriteCond %{THE_REQUEST} !\s/script/script\.php/?\??\S*\s [NC]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]