0

I use my own php mvc My htaccess:

php_flag display_errors on
php_value error_reporting 9999

RewriteEngine On
RewriteBase /sekilwak/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

How to rewrite "domain.com/user/index/username" to "domain.com/username"

1 Answer 1

2

First method is through .htaccess file you can write rewrite rules -

Write the following code in .htacces file in your project root directory

RewriteEngine on
RewriteRule ^/username/(.*)$ /user/index/username/$1 [R=301,NC,L]

You can Also Use Apache Rewrite Module -

If you are using CodeIgniter you can use Steps and code as below -

  • In your Project folder go application folder
  • Then Open Config folder
  • Then open routes.php go to end of file and add code below

    $route['username']="user/index/username";

It will automatically add domain.com to both side url's

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

1 Comment

@rule check the answer and let me know

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.