d.shankar Posted August 12, 2008 Author Share Posted August 12, 2008 Then it sounds like you have alot of work to do. You mean the renaming of 200 files ?? Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614396 Share on other sites More sharing options...
trq Posted August 12, 2008 Share Posted August 12, 2008 Exactly. Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614397 Share on other sites More sharing options...
d.shankar Posted August 12, 2008 Author Share Posted August 12, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614399 Share on other sites More sharing options...
discomatt Posted August 12, 2008 Share Posted August 12, 2008 You're going to have to change every local HREF to match your new URL scheme. Have fun Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614428 Share on other sites More sharing options...
Wolphie Posted August 12, 2008 Share Posted August 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614432 Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/119261-changing-php-files-to-xxx-and-accessing-it/page/2/#findComment-614517 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.