sameer kumar sameer kumar - 1 month ago 6
PHP Question

.htaccess rewrite rule for username and index along with other pages

I am developing one website of resume upload, user can register and submit there resume, later they ll see there resume by entering a custom link like,
now its all done but the thing is i rewrite an htaccess

RewriteRule ^profile/([^/]+)/?$ profile_view.php?user_custom=$1 [L,QSA,NC]

now I have the problem is the client wants the URL like

but when I rewrite the

RewriteRule ^([^/]+)/?$ profile_view.php?user_custom=$1 [L,QSA,NC]

by removing the
"profile/ "
then when ever am passing the username like

there is no problem but am facing the problem when i open
the index page lost along with all other pages.

Can any one suggest a solution?


You should exclude file and directories from your rule by adding RewriteCond just before your rule:

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/?$ profile_view.php?user_custom=$1 [L,QSA,NC]