Jump to content

HELP!!! Mod rewrite..


chaiwei

Recommended Posts

Hi,

 

I am totally new to the mod rewrite..

 

I want to hide the .php

eg.

 

i want to  use --> www.example.com/login

 

instead of -------> www.example.com/login.php

 

I create a .htaccess file then i write Rewrite Engine on

 

Any good guides or references for beginner?

 

Thanks in advance

 

Link to comment
Share on other sites

Hi,

 

I got another problems.

1)If i am using 198.162.2.3/chaiwei/login.php

  Can I using mod Rewrite to change it become 198.162.2.3/chaiwei/login??

 

2)What probably name to refer 198.162.2.3 (local address)?

  Then www.example.com is (external address)?

 

3)let say when i am outside my office i am using www.example.com to access

  But in my office i can't use www.example.com

  I need to use 198.162.2.3 to access.

  Is it they disable something?

  How can we enable back?

 

 

 

regards,

chaiwei

Link to comment
Share on other sites

Hi,

 

I got another problems.

1)If i am using 198.162.2.3/chaiwei/login.php

   Can I using mod Rewrite to change it become 198.162.2.3/chaiwei/login??

 

2)What probably name to refer 198.162.2.3 (local address)?

   Then www.example.com is (external address)?

 

3)let say when i am outside my office i am using www.example.com to access

  But in my office i can't use www.example.com

  I need to use 198.162.2.3 to access.

  Is it they disable something?

  How can we enable back?

 

 

 

regards,

chaiwei

 

 

1)  That should work without changing anything.

 

2)  Not sure what you're asking.  Domain names are usually external, although I have seen them resolve to LAN IPs before (my school does that with a bunch of subdomains, for example).  If you mean what is 192.blah..., that is a LAN IP.

 

3)  This could be multiple things.  If it works from outside, but not inside, it's most likely a weird router issue or ISP issue or something.  Some ISP don't allow an IP to make a request to it's self.  Appears to be a waste of bandwidth to them since accessing it over a WAN seems redundant.  It could also be your router confused, or it could be some other things too.  It does work from outside though, yes?

Link to comment
Share on other sites

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule ^(.*) /$1.php

 

I need to change anything to make it run?

eg.

SCRIPT_FILENAME >> Did I need to change it to login.php?

how about the $1.php Did I need to change it to $login.php?

 

Oh,so the 192.. is called LAN IP.

Then the www.example.com is called domain name?

 

3) yes,we can access the website from outside by using the www.example.com, but from inside we need to use 192.168.2.2

 

4) I have already tested the code, but it still shown 192.168.2.3/chaiwei  /login.php.

 

FYI I put the .htaccess file inside the chaiwei folder. Is that correct?

 

Link to comment
Share on other sites

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule ^(.*) /$1.php

 

I need to change anything to make it run?

eg.

SCRIPT_FILENAME >> Did I need to change it to login.php?

how about the $1.php Did I need to change it to $login.php?

 

Oh,so the 192.. is called LAN IP.

Then the www.example.com is called domain name?

 

3) yes,we can access the website from outside by using the www.example.com, but from inside we need to use 192.168.2.2

 

4) I have already tested the code, but it still shown 192.168.2.3/chaiwei   /login.php.

 

FYI I put the .htaccess file inside the chaiwei folder. Is that correct?

 

 

1)  You shouldn't need to change anything.

 

2)  Yes.  Yes.

 

3)  I don't know.  That's weird.

 

4)  Try going to http://192.168.2.3/chaiwei/login

 

And no, you should only need to put it in your document root.

Link to comment
Share on other sites

Hi Corbin,

 

yes It works (192.168.2.3/chaiwei/login)

But if I remove it will it not function?

But if I am still type 192.168.2.3/chaiwei/login.php

It still can work. But it still show 192.168.2.3/chaiwei/login.php

 

I want it to remove the .php

Any ways to prevent that?

Thanks.

Link to comment
Share on other sites

Hi corbin,

 

thanks a lot of your help.

It doesn't work properly. It still shown the .php

but

192.168.2.3/chaiwei/login (this works)

and

192.168.2.3/chaiwei/login.php (this works either)

 

I want to hide the .php and redirect to 192.blahblah../login

 

really appreciate for your help. Now I know more about the mod rewrite.

Thank You.

Link to comment
Share on other sites

  • 6 months later...

Hi Corbin,

 

yes It works (192.168.2.3/chaiwei/login)

But if I remove it will it not function?

But if I am still type 192.168.2.3/chaiwei/login.php

It still can work. But it still show 192.168.2.3/chaiwei/login.php

 

I want it to remove the .php

Any ways to prevent that?

Thanks.

 

create a folder call login.

add an index.php file in there with the login.php stuff.

 

 

Link to comment
Share on other sites

Anyone know how to solve the problems?

 

(when the time user type this url)

www.example.com/chaiwei/login.php

 

it will rewrite the url and display 

 

www.example.com/chaiwei/login

 

Create another htacces and upload to your directory

 

www.example.com/chaiwei/.htaccess

 

Then in this htaccess file add:

 

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^chaiwei/login  login.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.