943,647 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 717
  • PHP RSS
May 4th, 2009
0

Need help in .htaccess

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
coolmind259 is offline Offline
34 posts
since Apr 2009
May 4th, 2009
0

Re: Need help in .htaccess

Try this:
PHP Syntax (Toggle Plain Text)
  1. RewriteEngine On
  2. RewriteRule ^([^.]+[^/])$ index.php?req=$1
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
May 4th, 2009
0

Re: Need help in .htaccess

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
coolmind259 is offline Offline
34 posts
since Apr 2009
May 4th, 2009
0

Re: Need help in .htaccess

the try this:
PHP Syntax (Toggle Plain Text)
  1. RewriteRule ^login$ login.php?req=preview&login_name=$1

or
PHP Syntax (Toggle Plain Text)
  1. RewriteRule ^([^.]+[^/])$ login.php?req=$1
If this is not your solution , then tel me clearly...
Last edited by Shanti C; May 4th, 2009 at 6:10 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
May 4th, 2009
0

Re: Need help in .htaccess

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.
PHP Syntax (Toggle Plain Text)
  1. RewriteEngine On
  2. RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?req=preview&login_name=$1
  3. RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?req=preview&login_name=$1
  4.  
  5. RewriteRule ^\.login$ index.php?req=login
Last edited by cwarn23; May 4th, 2009 at 6:20 am.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
May 4th, 2009
0

Re: Need help in .htaccess

Thank you for your help Cwarn.
Reputation Points: 10
Solved Threads: 0
Light Poster
coolmind259 is offline Offline
34 posts
since Apr 2009
May 4th, 2009
0

Re: Need help in .htaccess

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
coolmind259 is offline Offline
34 posts
since Apr 2009
May 5th, 2009
0

Re: Need help in .htaccess

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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: make it so double-select menu remembers DB entries... when updating record
Next Thread in PHP Forum Timeline: Need .htaccess Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC