2

In my application the original file name for "pro" is profile.php and I have used htaccess to write it.

Now I have a URL which looks like this: http://localhost/campuslife/pro?u=mchati.evelyn

for some reasons I want the URL to look like this

http://localhost/campuslife/pro/mchati.evelyn

Please how do i achieve this?

what I tried :

RewriteEngine On
RewriteRule ^pro$ profile.php [L]

1 Answer 1

2

Inside /campuslife/.htaccess you can use this rule:

RewriteEngine On

RewriteRule ^pro$ profile.php [L,NC]

RewriteRule ^pro/([^/]+)/?$ profile.php?u=$1 [L,NC,QSA]
Sign up to request clarification or add additional context in comments.

3 Comments

Not working for me...when I tried it all my css files, js files and img cannot load and it make my page scattered.
For css/js/images problem is not this rule but your use of relative paths. To fix you can add this just below <head> section of your page's HTML: <base href="/" />
It works like a miracle!!! Thank you anubhava...best place to learn and to get help is STACKOVERFLOW!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.