Jump to content

Changing .php files to .xxx and accessing it


d.shankar

Recommended Posts

Hi all,

 

I have more than 200 php files in my webserver.. index.php,profile.php,stats.php,etc..........

 

Now i need to access these files with the .xxx extension.

 

if the user requests for www.mysite.com/profile.xxx , the profile page should be loaded..

 

I dont have access to my http.conf , so i have added these changes in my .htaccess

AddType application/x-httpd-php .xxx

 

But it is really not feasible to change all my .php filenames to .xxx

 

Is there any way to do this ?

Link to comment
Share on other sites

As suggested by the previous poster, mod_rewrite should do it for you. You can define manually which urls must be rewritten like (profile.php >> profile.html) if u dont want all the files changed. This guide helped me get the basics of mod_rewrite when i wanted to seo my urls.

 

EDIT: Im definitely not a mod_rewrite guy and pretty new to this. Just wanted also to post a line which u can use to convert somepage.php to somepage.html. Hope this helps:

 

RewriteRule ^index\.html$ /index.php
RewriteRule ^profile\.html$ /profile.php

 

The same concept can be used for other files and even other extensions.

Link to comment
Share on other sites

You could do automatic renaming with a program, or tell mod_rewrite to change all requests for .xxx files do a server-side rewrite to .php files.... it would allow you to keep the files (and scripts) with .php extensions but also have your visitor type yourpage.xxx.

 

eg. a request for index.xxx really be a request for index.php

 

Link to comment
Share on other sites

I'm going to take a shot at this, but this will probably not work...

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).xxx$ $1.php [QSA,L]
RewriteRule ^/$ index.xxx
</IfModule>

 

Put that in your .htaccess file in your htdocs folder. That PROBABLY won't work because it's just a splice from the mod_rewrite I use, but it's worth looking into.

 

It also makes index.xxx your default index file.

Link to comment
Share on other sites

There is some way to do it, unfortunately it seems like no one that knows mod_rewrite really well is on...

 

try this instead of what I posted before... (and remove that redirect you posted a sec ago of course)

 

RewriteEngine on
RewriteRule ^(.*)\.xxx $1\.php 

 

or

 

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^.]+).xxx$ /$1.php [QSA,L]

 

then visit a page... like index.xxx (when you have a file named index.php in that dir)

 

one of those SHOULD work

 

EDIT: ps. all of this was very slightly modified from the things found

http://forums.digitalpoint.com/showthread.php?t=5801 <== here

 

there are a few more mod_rewrites there you can try if the ones above don't work for you, just replace .html with .xxx

Link to comment
Share on other sites

This is what I use:

 

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

RewriteRule ^([^/\.]+)/?$ /index.php?q=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?view=$1&id=$2 [L]
# RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?section=$1&subsection=$2&page=$3 [L]

# These rewrite rules can be used over and over for different master pages.
# For example, see below.

# RewriteRule ^([^/\.]+)/?$ /profile.php?user_id=$1 [L]
# RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /profile.php?category=$1&page=$2 [L]
# RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /profile.php?category=$1&subcategory=$2&page=$3 [L]

 

However I doubt that would be sufficient enough for over 200 different filenames. However, it should help you out a bit. Hopefully.

Link to comment
Share on other sites

Hmmm ... Do you really think this the correct way to go?

I mean, this is security through obscurity - every security hole that is present in your code still exist (and can be exploited).

What you are hiding is only the fact that is written in PHP (and making an URL a bit more beautiful)

 

You should design your application/web page to be secure from the ground up.

Start by reading this tutorial.

 

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.