0

I want to create a dynamic URL using .htaccess file. I designed a website, its URL is:

localhost/social_adv/     

I want to create a dynamic URL like below, where the user is dynamically fetched from the database:

localhost/social_adv/user

Here's my rewrite rule:

RewriteEngine On  
RewriteRule ^custom woddev/user [NC,L]
1
  • does /user directory is exist ? Commented Jan 2, 2017 at 7:12

1 Answer 1

1

I assume user is a placeholder and needs to be dynamically set. Try this:

Options +FollowSymLinks

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteRule ^social_adv/(.*)$ /woddev/$1 [L]
</IfModule>

It will match any social_adv/USER request (where USER is a placeholder) and maps it to woddev/USER under the hood. For example, this URL:

localhost/social_adv/shiva

Will be mapped to:

localhost/woddev/shiva
Sign up to request clarification or add additional context in comments.

3 Comments

Your code is absolutely correct sir, i think my project is not supported. My controller is not execute after including your code, the error is page not found
What you get when you hit the woddev/whatever-here in your browser? Does the CodeIgniter app reside in woddev/ or social_adv? Or both?
worked for me. This is simpler than most other answers in other pages.

Your Answer

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