0

I have a URL like http://www.psreducators.com/agent-profile/?u=donald-mark, but I want the users to see the URL as http://www.psreducators.com/agent-profile/donald-mark. (donald-mark is the user profile name.)

How can I achieve this using .htaccess RewriteRule directives?

  • 1
    There is no need to use a get parameter with EE. Is this a channel entry or is it pulling from the member profile itself? – Jim Wyse Sep 14 '15 at 11:43
0

One method would be to use an .htaccess RewriteRule to make URI's that look like that:

 http://www.psreducators.com/agent-profile/?u=[user-profile-name]

to be rewritten like this:

 http://www.psreducators.com/agent-profile/[user-profile-name]

For this, you would use a RewriteRule. Here is an example:

RewriteRule ^agent-profile.php\/?u=(.*)$ agent-profile.php/$1/ [L,NC,R=301]

This will capture anything after the u= GET param, and the place it in the $1 of the second param of the rewrite. It will be a permanent redirect (R=301), it will ignore case when matching (remove the NC of the flags if you don't want that), and if this is matched, the .htaccess file will not bother trying any rules after it (L[ast]). This is untested, but should get you going.

| improve this answer | |
  • Could you clarify what these rules do? Also, where they belong (i.e., in the root .htaccess file, after the index.php rewrite, hint hint)? – jrothafer Sep 22 '15 at 22:05
  • 1
    Sorry but your answer needed a lot of expansion to not be low quality. – jrothafer Sep 22 '15 at 23:03
0

You can try the following .htaccess rules (tested).

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /agent-profile/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /agent-profile/index.php [L]
</IfModule>

Add the following code to your index.php file.

<?php
  header("HTTP/1.0 200");
?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.