One thing I did for dmb is making dodosmb.com/profile/username work with my profile.php script. Normally without the help of .htaccess, you can use the value of the path info from the global variable
$_SERVER['PATH_INFO']
For example, create a php file named profile.php and in there put:
<?php echo $_SERVER['PATH_INFO']; ?>
Then upload the file and load it with yourServerPath/profile.php/dodo. The script will print out
/dodo
In my profile.php, I get the user by doing a simple sub string command like:
$user = substr($_SERVER['PATH_INFO'], 1); // this will get rid of the leading slash
This allows me to feed users to my profile.php by using the url dodosmb.com/profile.php/username
That’s still not pretty enough; it’s better if I can do dodosmb.com/profile/username. This is where .htaccess rewrite comes in. Here’s a great tutorial for .htaccess rewrite rules. To accomplish my goal, I used the following rewrite rules in my .htaccess:
RewriteEngine on RewriteRule ^profile/([A-Za-z0-9]+)/$ /profile.php/$1 RewriteRule ^profile/([A-Za-z0-9]+)$ /profile.php/$1
Nice tip. 🙂 Thanks!
I’m about to develop a php based website and I found your thread.
Thank god that’s exactly what I’m looking for! :heart:
Some comments/suggestions on your URL rewrite code. You have duplicates in the list for with and without a slash.
RewriteEngine on
RewriteRule ^profile/([A-Za-z0-9]+)/$ /profile.php/$1
RewriteRule ^profile/([A-Za-z0-9]+)$ /profile.php/$1
It is easier if you simply make the slash optional using a regex question mark following the slash. This eliminates the need for two rules to do the same thing.
RewriteEngine on
RewriteRule ^profile/([A-Za-z0-9]+)/?$ /profile.php/$1
Also, it may be necessary to enable the FollowSymLinks option to get the server to actually do the rewrite. You would add the following to the top of the .htaccess to be sure it was enabled.
Options +FollowSymLinks
So, if you followed both suggestions, your new .htaccess would look like this.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^profile/([A-Za-z0-9]+)/?$ /profile.php/$1
i have created rule for following url
http://www.amg.biz/garavigujarat as below
RewriteEngine On
RewriteBase /
DirectoryIndex index.php default.php Default.php
RewriteCond %{QUERY_STRING} ^(.*)
RewriteRule ^garavigujarat$ http://www.amg.biz/index.php?page=Publications&id=2
but instead of showing original url it’s showing new url. so i think it’s redirecting instead of rewriting url.
can you please help me.
i am currently use zazavi 1.2.1 version.
i have problem with URL mod_rewrite
original:
http://domain.com/view-content/2/link.html
i want this e.g.:
http://domain.com/link.html
WHY CHANGE ?
point is :- 1st this is save from database injection and hacker.. and SEO Friendly URL
because these number are page id in db.
any buddy help me to solve my problem
I truly love your blog.. Excellent colors & theme.
Did you build this amazing site yourself? Please reply back as
I’m looking to create my very own blog and want to learn where you got this from or just what the theme is named. Cheers!