Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: better way to navigate without using .php at the end of the URL.  (Read 1113 times)

captain102

  • Basic Member
  • *
  • Reputation Power: 2
  • captain102 has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
better way to navigate without using .php at the end of the URL.
« on: December 28, 2009, 04:50:23 PM »
I have been working with .htaccess for a while and I have found out how to do this. I've been working with video scripts like the one that youtube has and also metacafe has and stuff. I have these for free because I thought people might find this useful.

in the .htaccess file, just write in this
RewriteCond %{REQUEST_URI} !.php

and below it, just write in this.
RewriteRule ^profile/?$ viewuser.php [L]

now to test it out, just go to http://www.mydomain.com/profile?u=1 and see if it works. This was an easy job for me when I found this out and I thought this would save room in the URL and stuff. I hope this works for everything.

cheers.
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: better way to navigate without using .php at the end of the URL.
« Reply #1 on: December 28, 2009, 05:30:38 PM »
Do we have to change any links?
Logged
Project Choosen - 10%
Daniel - Hanson . Com

captain102

  • Basic Member
  • *
  • Reputation Power: 2
  • captain102 has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: better way to navigate without using .php at the end of the URL.
« Reply #2 on: December 28, 2009, 05:53:24 PM »
no. it's just simple. you don't have to change URLs. the .htaccess just looks at the URL and see what your trying to look at and it just navigates though the site. like if you have a file that is in a folder in a folder and in an other folder, you can just type in the URL that doesn't grab the specific location but does go to the file without it giving error messages.

pretty simple if you ask me.
« Last Edit: December 28, 2009, 05:58:36 PM by captain102 »
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: better way to navigate without using .php at the end of the URL.
« Reply #3 on: December 28, 2009, 06:15:13 PM »
I was looking for this, and found this:
Code: [Select]
RewriteEngine On
RewriteBase /

# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]


# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
Logged
Project Choosen - 10%
Daniel - Hanson . Com

captain102

  • Basic Member
  • *
  • Reputation Power: 2
  • captain102 has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: better way to navigate without using .php at the end of the URL.
« Reply #4 on: December 28, 2009, 06:41:54 PM »
doesn't look like it's giving permission to a specific file. I think it is just....... I don't know. but it's different than what I have.
Logged

vlad

  • Basic Member
  • *
  • Reputation Power: 3
  • vlad has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
    • WWW
    • Email
Re: better way to navigate without using .php at the end of the URL.
« Reply #5 on: January 01, 2010, 05:43:42 AM »
So Basicly it will remove php at the end which will do what exactly?Will it make it more secure or anythink like that?
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: better way to navigate without using .php at the end of the URL.
« Reply #6 on: January 01, 2010, 08:34:03 AM »
No, ever seen pro sites, they dont have the .php/.html on it. Even this one doesnt ;)
Logged
Project Choosen - 10%
Daniel - Hanson . Com

KDawg08

  • Basic Member
  • *
  • Reputation Power: 1
  • KDawg08 has no influence.
  • Offline Offline
  • Posts: 3
    • View Profile
Re: better way to navigate without using .php at the end of the URL.
« Reply #7 on: January 19, 2010, 11:09:34 PM »
I was looking for this, and found this:
Code: [Select]
RewriteEngine On
RewriteBase /

# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]


# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

I Tried this one on my mccodes scripts .htaccess file and i get this.

Not Found

The requested URL /explore was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Haha unfortunately didn't work for me
Logged

gambino

  • Active Member
  • **
  • Reputation Power: 0
  • gambino is looked down upon.gambino is looked down upon.gambino is looked down upon.
  • Offline Offline
  • Posts: 113
    • View Profile
Re: better way to navigate without using .php at the end of the URL.
« Reply #8 on: January 20, 2010, 11:39:22 AM »
I get how this thing works. I have been testing it. it's not like one of y'all codes for the .htaccess ones. it's more like this for example
Quote
RewriteEngine on

RewriteCond %{REQUEST_URI} !.php
RewriteRule ^profile?$ viewuser.php [L]
RewriteRule ^staff?$ staff.php [L]
RewriteRule ^mailbox?$ mailbox.php [L]
RewriteRule ^events?$ events.php [L]
RewriteRule ^logout?$ logout.php [L]
RewriteRule ^login?$ login.php [L]


RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$

Use this and see what you think on how it works. first off, just put in http://mydomain.com/login and you will see how it looks. At least you can stop people from trying to hack your site with a code they think it is.
Logged

Zeddicus

  • Basic Member
  • *
  • Reputation Power: 0
  • Zeddicus is looked down upon.Zeddicus is looked down upon.
  • Offline Offline
  • Posts: 42
    • View Profile
    • WWW
Re: better way to navigate without using .php at the end of the URL.
« Reply #9 on: January 21, 2010, 01:04:28 PM »
It doesn't stop hacking at all. -_-
Logged

catles

  • Basic Member
  • *
  • Reputation Power: 24
  • catles has no influence.
  • Offline Offline
  • Posts: 26
    • View Profile
    • WWW
    • Email
Re: better way to navigate without using .php at the end of the URL.
« Reply #10 on: January 21, 2010, 03:20:29 PM »
for the staff panel it can mess them up a bit.... cuz you can cnage the .php to one of the others php uses and the user would have no clue what to do
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.