chaiwei Posted November 21, 2008 Share Posted November 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/ Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*) /$1.php Just google around and you should be able to find some tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695005 Share on other sites More sharing options...
chaiwei Posted November 21, 2008 Author Share Posted November 21, 2008 Hi Corbin, thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695068 Share on other sites More sharing options...
chaiwei Posted November 21, 2008 Author Share Posted November 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695082 Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695100 Share on other sites More sharing options...
chaiwei Posted November 21, 2008 Author Share Posted November 21, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695122 Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695130 Share on other sites More sharing options...
chaiwei Posted November 21, 2008 Author Share Posted November 21, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695154 Share on other sites More sharing options...
chaiwei Posted November 21, 2008 Author Share Posted November 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695177 Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 Try adding (untested... might cause a loop): RewriteRule /(.*)\.php /$1 [R=301,L] Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695806 Share on other sites More sharing options...
chaiwei Posted November 22, 2008 Author Share Posted November 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695940 Share on other sites More sharing options...
chaiwei Posted November 22, 2008 Author Share Posted November 22, 2008 Hi Corbin, Is it might be my server can't support mod rewrite? Because I try this 1 RewriteCond %{HTTP_HOST} 192.168.2.3 RewriteRule .* you-are-banned.html [R] It suppost show me the url you-are-banned.html, right? but it still show me 192.168.2.3 which I saw in http://www.easymodrewrite.com/guide-advanced Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-695947 Share on other sites More sharing options...
help me please Posted June 13, 2009 Share Posted June 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-854946 Share on other sites More sharing options...
dreamwest Posted June 15, 2009 Share Posted June 15, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/133598-help-mod-rewrite/#findComment-855969 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.