0

I need for my .htaccess file to take away the .php file extension and replace it with just a trailing slash.

Also, I have a profile.php page which will normally be visited with a numeric querystring parameter, like "profile.php?id=3".

So on top of replacing extensions with slashes, how do I make "profile.php?id=3" look like "profile/3/"?

So far all I have is the first line:

RewriteEngine on

Where do I go from here?

1

2 Answers 2

4

If you're so new... you really should read the manual.

// if not a file
RewriteCond %{SCRIPT_FILENAME} !-f
// if not a directory
RewriteCond %{SCRIPT_FILENAME} !-d
// pass all params back to index.php
// QSA stands for query string append
// L stands for last rule
RewriteRule (.*) index.php?$1 [QSA,L]

But this will do what you want. Now don't be lazy. Read the manual!

Sign up to request clarification or add additional context in comments.

2 Comments

Pointless telling him not to be lazy after you've done the work for him :P
@MrXexxed, you're right... you're right... shouldn't have! :)
0

This should do it

RewriteRule ^profile/(.*)$ profile.php?id=$1 [NC,L]

Comments

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.