FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Rewrite Rule in .htaccess





AOP Web Development
Hello i have encounters some of the site instead that their site is a seo friendly.. now i just like to ask how do they do that.. i have search that using a rewrite rue for .htaccess

for example if you have a
http://www.example.com/services.php , http://www.example.com/aboutus.php, http://www.example.com/contactus.php

then what i want is to make it like this

http://www.example.com/services/, http://www.example.com/aboutus/,
http://www.example.com/contactus/

something like that or for example

http://www.example.com/data.php?cmd=link

well become:

http://www.example.com/data/link

it's something link that i hope you can share anything about this... As of now im trying to study the basic rewriting rule but still it's fail... and another thing is it possible that you can write a script for it to modify the .htaccess to implement the this rewriting rule or you have to do it manually by editing the .htaccess

i hope you can share some thoughts thanks........


Razz Razz Razz Razz
Diablosblizz
Google MODRewrite. I think thats what it is called. I am not sure how to get it to work though..
DanielXP
Code:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^data/(.*)/$ data.php?cmd=$1 [L]
RewriteRule ^(.*)/ $1.php [L]
AOP Web Development
hello thanks for the sample code you shared... but i just like to ask if is it possible that i can modify the .htaccess through phpscript, or i have to do it manually to the .htaccess
pawelabrams
perhaps you can by file_put_contents, but the script can be dangerous...
swizzy
you have to manually edit .htaccess in CP/DA

Code:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^data/(.*)/$ data.php?cmd=$1 [L]
RewriteRule ^(.*)/ $1.php [L]


the code basically passes the text behind the / sign as a parameter to data.php
Stubru Freak
AOP Web Development wrote:
hello thanks for the sample code you shared... but i just like to ask if is it possible that i can modify the .htaccess through phpscript, or i have to do it manually to the .htaccess


You can, but probably not the way you intend to.
If you do it in PHP, the script has to be executed, and for that it has to be found, BEFORE you get the chance to edit anything in the .htaccess.
AOP Web Development
Yes i guess so it's very dangerous to do it, i think i will just manually modify the mod rewriting after i have to code some functions or vice versa.
ixtra
AOP Web Development wrote:
Hello i have encounters some of the site instead that their site is a seo friendly.. now i just like to ask how do they do that.. i have search that using a rewrite rue for .htaccess

for example if you have a
http://www.example.com/services.php , http://www.example.com/aboutus.php, http://www.example.com/contactus.php

then what i want is to make it like this

http://www.example.com/services/, http://www.example.com/aboutus/,
http://www.example.com/contactus/

something like that or for example

http://www.example.com/data.php?cmd=link

well become:

http://www.example.com/data/link

it's something link that i hope you can share anything about this... As of now im trying to study the basic rewriting rule but still it's fail... and another thing is it possible that you can write a script for it to modify the .htaccess to implement the this rewriting rule or you have to do it manually by editing the .htaccess

i hope you can share some thoughts thanks........


Razz Razz Razz Razz


So how can you make http://www.example.com/contactus.php into http://www.example.com/contactus/
and others?
Stubru Freak
ixtra wrote:
So how can you make http://www.example.com/contactus.php into http://www.example.com/contactus/
and others?


Code:
RewriteEngine On
RewriteRule ^(.*)$ $1.php
Related topics
htaccess
Move to subdomain without causing 404 errors on old pages?
php (phpBB) help
mod rewrite - danger?
how to make old html point to php
rewrite rule htaccess
PHP and .htaccess
simple URL redirection
Nice htaccess trick for disallowing downloading
Show People's IP In a Pic
How to make javascript alert bomb work on operamini browser?
.htaccess rewrite not working - any suggestions
htaccess pattern for an email
Apache mod_rewrite questions.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.