php - Combine two different rules in HTACCESS -


i able create rule in htaccess file, hide sub-folder.

 rewriteengine on   rewritecond %{the_request} ^[a-z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [nc]  rewriterule ^ /%1/%3 [r=301,l]   rewritecond %{request_filename} !-d  rewritecond %{request_filename} !-f  rewriterule ^([^/]+)/([^/]+)/?$ $1/project/$2.php [nc,l] 

the first rule removes file-extensions : php

the second rule hide folder "project" url

both these rules working perfectly.

however, when tried add third rule, hide folder, failed.

this second folder (rolan) in same location "project" folder, assumed should work copy-pasting second rule :

 rewriteengine on   rewritecond %{the_request} ^[a-z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [nc]  rewriterule ^ /%1/%3 [r=301,l]   rewritecond %{request_filename} !-d  rewritecond %{request_filename} !-f  rewriterule ^([^/]+)/([^/]+)/?$ $1/project/$2.php    rewritecond %{request_filename} !-d  rewritecond %{request_filename} !-f  rewriterule ^([^/]+)/([^/]+)/?$ $1/rolan/$2.php [nc,l] 

(please note : removed [nc,l] end of second rule, , placed @ end of third rule.)

both first , second rules still working. but, third rule, getting "file not found : 404" error

update

i have modified htaccess file, follows :

 rewriteengine on  rewritecond %{the_request} ^[a-z]{3,}\s/?([^/]+)/([^/]+)/([^.]+)\.php [nc]  rewriterule ^ /%1/%3 [r=301,l]   rewritecond %{request_filename} !-d  rewritecond %{request_filename} !-f  rewriterule ^([^/]+)/([^/]+)/?$ $1/project/$2.php  rewriterule ^gagoo/([^/]+)/([^/]+)/?$ $1/rolan/$2.php [nc,l] 

i added prefix "gagoo" third rule.

then, in php code, use url : /gagoo/rolan/file_name

but, still getting 404 error.

i tried removing "rolan" url : /gagoo/file_name

and, still no luck.

actually, way rule works, "rolan" not supposed included in url (after all, purpose of rule hide "rolan" folder display in browser........the same way second rule hides "php" folder)


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -