开发者

shorten url problem using htaccess

开发者 https://www.devze.com 2023-03-27 14:12 出处:网络
I need to change http://localhost/engineering/management/administrator/modules/course/view.php to http://localhost/engineering/course_view.php

I need to change

http://localhost/engineering/management/administrator/modules/course/view.php

to

http://localhost/engineering/course_view.php

using htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.php$   management/administrator/modules/$1/$2.p开发者_如何学JAVAhp
RewriteRule ^(.*)_(.*)\.php$   management/user/modules/$1/$2.php

Works fine for this,

But for the below url its not working

http://localhost/engineering/management/user/modules/data/edit.php


Please try with this code:-

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/$1/$2.php
RewriteRule ^(.*)_(.*)\.php$ management/user/modules/$1/$2.php

Hope it helps.


when you use this one!

RewriteRule   (.*)_(.*)\.php  management/administrator/modules/$1/$2.php

because it's possile ro rewrite other URLs(that you've mentioned), you can add special part to it to avoid such thing. e.g:

RewriteRule   swd(.*)_(.*)\.php  management/administrator/modules/$1/$2.php

and url:

http://localhost/engineering/swdcourse_view.php

and for second one, use other characters than swd!!

RewriteRule   ^usr(.*)_(.*)\.php$  management/user/modules/$1/$2.php
0

精彩评论

暂无评论...
验证码 换一张
取 消