RewriteOptions inherit
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^profile/([^/]+)/?$ https://example.com/?username=$2 [L,QSA,NC]
RewriteRule ^profile/(followers|friends|saved|stories)/([^/]+)/?$ $1.php?username=$2 [L,QSA,NC] 

I have also tried this rule too

RewriteRule ^profile/([^/]+) /?username=$2 [L,QSA,NC] 

But, when I visit the /user/ or /profile/user/ links after making these changes, they forward to a 404 Page Not Found.

  • What are the intended targets for such requests. Please give examples in natural language of the intended from/to mappings. In the first rule, what is the intended file that should handle the request?
    – MrWhite
    Commented Apr 22 at 8:26
  • ... what URLs are you actually requesting? (What rules are your "inheriting"?)
    – MrWhite
    Commented Apr 22 at 9:43
  • Have you confirmed that .htaccess overrides are enable? What version of Apache are you using? A request of the form /profile/user/ should trigger an external 302 redirect to root, given the rules above. If you are not seeing that then it doesn't look like those rules are doing anything.
    – MrWhite
    Commented Apr 22 at 10:33


Your Answer

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

Browse other questions tagged or ask your own question.