954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help in .htaccess

Hi Guys!

I have a url like www.mysite.com/index.php?req=login

I want it like that www.mysite.com/login

I want to hide php extension from that. Please reply.

Thank you
Take care.

coolmind259
Light Poster
34 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Try this:

RewriteEngine On
RewriteRule ^([^.]+[^/])$ index.php?req=$1
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Hi Cwarn,

Thank you for your reply.

The problem is that I have this code already in my .htaccess file

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1L]

this code turns this url
mysite.com/index.php?req=preview&login_name= 'somename'

into
mysite.com/somename

So, this code does not let the code work that you told me like.

RewriteEngine On
RewriteRule ^([^.]+[^/])$ index.php?req=$1

which turns this url www.mysite.com/index.php?req=login

into

mysite.com/login

So, what will be the solution.

Your help in this matter will be highly appreciated. Thank you.

Take care.

coolmind259
Light Poster
34 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

the try this:

RewriteRule ^login$ login.php?req=preview&login_name=$1


or

RewriteRule ^([^.]+[^/])$ login.php?req=$1

If this is not your solution , then tel me clearly...

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

Hi Cwarn,

Thank you for your reply.

The problem is that I have this code already in my .htaccess file

RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1L]

this code turns this url mysite.com/index.php?req=preview&login_name= 'somename'

into mysite.com/somename

So, this code does not let the code work that you told me like.


Well then that means that you will need to have a escape character so login and any other new entries can pass by the existing entries. So for example, instead of having just login as the prefix you would need something like .login
Below is an example for.login as the ending prefix.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1

RewriteRule ^\.login$ index.php?req=login
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Thank you for your help Cwarn.

coolmind259
Light Poster
34 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Hi Cwarn,

I have uploaded the .htaccess file on the main server with the name of htaccess but it is not working fine.

The server cannot find the file which I wanted to access though .htaccess.

Please help

Thank you.

coolmind259
Light Poster
34 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Then did you place the .htaccess file in the same directory/folder as the index.php page? Also, did you remember to place the dot before the word login within the login. So the url should be something like http://www.example.com/.login Also check that the real file responds when using the real address.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You