Need help in .htaccess

Thread Solved

Join Date: Apr 2009
Posts: 34
Reputation: coolmind259 is an unknown quantity at this point 
Solved Threads: 0
coolmind259 coolmind259 is offline Offline
Light Poster

Need help in .htaccess

 
0
  #1
May 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,449
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Need help in .htaccess

 
0
  #2
May 4th, 2009
Try this:
  1. RewriteEngine On
  2. RewriteRule ^([^.]+[^/])$ index.php?req=$1
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 34
Reputation: coolmind259 is an unknown quantity at this point 
Solved Threads: 0
coolmind259 coolmind259 is offline Offline
Light Poster

Re: Need help in .htaccess

 
0
  #3
May 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Need help in .htaccess

 
0
  #4
May 4th, 2009
the try this:
  1. RewriteRule ^login$ login.php?req=preview&login_name=$1

or
  1. RewriteRule ^([^.]+[^/])$ login.php?req=$1
If this is not your solution , then tel me clearly...
Last edited by Shanti Chepuru; May 4th, 2009 at 6:10 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,449
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Need help in .htaccess

 
0
  #5
May 4th, 2009
Originally Posted by coolmind259 View Post
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.
  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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 34
Reputation: coolmind259 is an unknown quantity at this point 
Solved Threads: 0
coolmind259 coolmind259 is offline Offline
Light Poster

Re: Need help in .htaccess

 
0
  #6
May 4th, 2009
Thank you for your help Cwarn.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 34
Reputation: coolmind259 is an unknown quantity at this point 
Solved Threads: 0
coolmind259 coolmind259 is offline Offline
Light Poster

Re: Need help in .htaccess

 
0
  #7
May 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,449
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Need help in .htaccess

 
0
  #8
May 5th, 2009
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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC