Reputation: 3484
I have a yii app that has separate back end and front end. I am trying to make friendly url. I have tried some online tools but could not get it correct So I want this url
http://mydomain.lc/abs/admin/some/crazy/urls
(for example
some/crazy/urls can be admin/index)
will be rewritten to:
http://mydomain.lc/abs/backend.php/some/crazy/urls
(because this
url works directly)
And I have also front end site but they are both in the same project so they share .httacess. the rule for .htaccess for front end is: this url:
http://mydomain.lc/abs/some/crazy/urls
(some can not be admin
here, so we can differentiate btw fron and back end)
should be
http://mydomain.lc/abs/index.php/some/crazy/urls
I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^abs/admin/?(.*?)$ abs/backend.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!abs/admin\/)(.*?)$ abs/index.php?url=$1 [QSA,L]
</IfModule>
the above script is not working. Root is under abs folder and .htaccess in the root
Upvotes: 0
Views: 1708
Reputation: 104
You do not have to change anything except RewriteBase /
to RewriteBase /abs
RewriteEngine On
RewriteBase /abs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/?(.*?)$ backend.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!admin\/)(.*?)$ index.php?url=$1 [QSA,L]
Upvotes: 1
Reputation: 11809
I guess the problem is with the RewriteBase
.
You may try this in the .htaccess file in /abs
directory:
Update according to last OP comment: this one is correct: backend.php/some/crazy/urls
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /abs
# Backend admin
RewriteCond %{REQUEST_URI} !backend\.php [NC]
RewriteRule ^admin(.*) /backend.php/$1 [QSA,L,NC]
# Frontend
RewriteCond %{REQUEST_URI} !index\.php [NC]
RewriteCond %{REQUEST_URI} !admin [NC]
RewriteRule ^(.*) /index.php/$1 [QSA,L,NC]
Upvotes: 1