AGK
AGK

Reputation: 99

Need short URl for my Site htaccess

I need to change

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

to

http://localhost/engineering/course_view.php

I tried the following rewriting

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

But it does not affect the url. I think the code has some problem.

Upvotes: 1

Views: 376

Answers (2)

Architect
Architect

Reputation: 363

Here we go:

Options +FollowSymlinks
 RewriteEngine on
 RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/course/view.php

Since you are in localhost and inside the folder engineering, you can omit that in rule. This works only if you place the .htaccess inside the engineering folder.

http://localhost/engineering/course_view.php

Thanks,

Najeem

Upvotes: 1

rMX
rMX

Reputation: 1090

Just delete '[' ']' from your rule.

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

UPD Added '/' at the beginnig of replace pattern.

P.S. Sorry, I can't check this rule myself. Haven't apache installed on my pc.

Upvotes: 1

Related Questions