I am trying to load a page (/user/profile.php) whenever the URL is sitename.com/u/[user_nicename] How to achieve this by mod rewrite ?
I have tried the following but it is not redirecting properly,(shows 404 err)
here is my htaccess content,
RewriteEngine On
RewriteRule ^u/([^/.]+)/?$ /user/profile.php [L]
(I have created this .htaccess file in 'u' directory so that when a request like example.com/u/[something] is made, it will look for [something] file, when that is not found it tries to find 'u' directory where I have written this redirect)
Kindly help, all I am trying is to load a particular file ie., /user/profile.php
whenever a request is like sitename.com/u/[user_nicename]
Thanks!
try this:
RewriteRule ^/u/(.*) /user/profile.php [L]
Since, you have this .htaccess
inside the sub-directory u
is implicit and not required in the rule.
RewriteEngine On
RewriteRule ^([^/]+)/?$ /user/profile.php [L]