Siv Siv - 7 months ago 49
PHP Question

htaccess 2 mod_rewrite

I am a beginner in .htaccess can any one help me with this?

//my .htaccess code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /alumini/profile.php?username=$1

//with the above i can redirct the url




but i also want to hide loacalhost/alumini/index.php to loacalhost/alumini

in simple ....

i want an htaccess code to hide the index page also i need to convert





Your first request is a rewrite, not a redirect. Your second is a redirect. For the re-write, the following rule should do the trick (untested):

RewriteRule ^localhost/alumini/([a-zA-Z]+)$ /alumini/profile.php?username=$1

The regular expression inside the brackets matches one or more upper or lowercase letters and nothing else, and the value of the match is passed to $1. You may need to change the regular expression depending on the format of your usernames.

and for the index.php redirect (to remove the index.php where it exists):

Redirect 301 /alumini/index.php http://localhost/alumini

The 301 represents the fact that the page has moved permanently, and is better for SEO as only the non index.php page will be indexed.