Jump to content

Changing .php files to .xxx and accessing it


d.shankar

Recommended Posts

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.

 

Thanks wolf.

How should i hardcode a link in a htmlpage to a file called profile.php which is previously like this <a href='profile.php'>profile</a>

Link to comment
Share on other sites

You're going to have to change every local HREF to match your new URL scheme. Have fun ;)

Yes, you will.

 

As I mentioned before, this really isn't a sufficient method to use for a scale of 200 files give or take. Hence why you should use Clean URLs (mod_rewrite) when starting an application, that way you can put contingency and fail safes in place.

 

For a pre-built website with 200 files or more and hundreds if not thousands of redirects and anchor links, I'd for sure advise against this. On the other hand, if you were just starting this application. I'd support you all the way and advise you to use Clean URLs provided you have fail safes and contingency in place.

 

For a dynamic URL you would use something like..

 

http://domain.com/val1/val2/

http://domain.com/index.php?var1=val1&var2=var2

Link to comment
Share on other sites

And just so you know, this isn't going to make your site more secure.  It'll probably just help a tiny bit with SEO.  If there's an exploit, there's an exploit. Also, even if a page doesn't have a .php extension (like they rewrite foo-bar-25.html to foo.php?cat=bar&id=25 on some sites for example), you can still tell that it's dynamic and it's a good chance that it's PHP.  If you didn't start your application with mod_rewrite, it'll be a headache to convert it now.

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.