php - How can I rewrite URL's of a certain directory? -



php - How can I rewrite URL's of a certain directory? -

ok, vague question title, know. wasn't sure how summarize in 1 line. have 2 applications in codeigniter installation: frontend , admin. there 2 front end controllers each set right application folder. currently, utilize index.php/home home page of frontend , admin.php/home home page of admin panel.

i got around removing index.php url of frontend. admin cp, utilize example.com/admin instead of example.com/admin.php. need rewrite uri has admin first segment admin.php. figured adding rewriterule ^admin/(.*)$ admin.php/$1 htaccess trick, apparently doesn't... not anyway. 404 page not found every single page in admin cp. doing wrong?

# deny or allow folder indexes. # since disable access php files # can leave on without worries. # or improve yet, create .htaccess file in # dir want allow browsing , # set +indexes options -indexes options +followsymlinks # set default file indexes directoryindex index.php <ifmodule mod_rewrite.c> # mod_rewrite rules rewriteengine on # rewritebase of scheme (if using sytem in sub-folder). # rewritebase /codeigniter_1.6.3/ # create site accessible without "www." # (which maintain subdomain-sensive config file happy) # if want site accessed "www." # comment-out next 2 lines. # rewritecond %{http_host} ^www\.example\.com$ [nc] # rewriterule ^(.*)$ http://example.com/$1 [l,r=301] # if controler can't found - issue 404 error php # error messages (via "error" plugin) # errordocument 403 /index.php/403/ # errordocument 404 /index.php/404/ # errordocument 500 /index.php/500/ # deny people (or bots) next sites: (to stop spam comments) # rewritecond %{http_referer} nienschanz\.ru [nc,or] # rewritecond %{http_referer} porn\.com # rewriterule .* - [f] # note: if having problem url # add together above forbide visitors site. # can uncomment if know ip: # deny 192.168.1.1 # if file not index.php file rewritecond %{request_filename} !index.php # hide php files none can accessed http rewriterule (.*)\.php$ index.php/$1 # if file/dir not real go index rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [qsa,l] rewriterule ^admin/(.*)$ admin.php/$1 </ifmodule> # if mod_ewrite not installed go index.php <ifmodule !mod_rewrite.c> errordocument 404 index.php </ifmodule>

you need add together rule before index.php routing rule. it's because ^(.*)$ matching admin/whatever, admin rule never executed. should add together -multiviews options looks this:

options +followsymlinks -multiviews

then right under rewriteengine on, add together rule:

rewriterule ^admin/(.*)$ admin.php/$1 [l]

php .htaccess codeigniter mod-rewrite

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -