newb help: domain.com/register.php -> domain.com/register

Discuss practical ways rearrange URLs using mod_rewrite.

newb help: domain.com/register.php -> domain.com/register

Postby Guest » Sat Mar 12, 2005 7:41 pm

hopefully this can be done easily

any help is greately appreciated

thanks in advance
Guest
 

Postby Caterham » Sun Mar 13, 2005 10:18 am

Yes, this can be done easily.

What have you tried so far? Should this force an external redirech to domain.com/register or should register.php be calles internally when domain.com/register was requested?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sun Mar 13, 2005 12:48 pm

i would like it so the .php does not appear in the url

this is purely for asthetic reasons

thanks!
Guest
 

Postby Caterham » Sun Mar 13, 2005 1:32 pm

so it would be request of domain.com/register --> register.php

Code: Select all
RewriteEngine On
RewriteRule ^([^.]+) /$1.php [L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sun Mar 13, 2005 3:00 pm

hmm that doesnt seem to work

heres what i had previously:

RewriteEngine On
RewriteRule ^site/(.*) /detail.php?siteid=$1
RewriteRule ^cat/(.*) /index.php?catid=$1

is something there conflicting with the new rule?
Guest
 

Postby Caterham » Sun Mar 13, 2005 3:07 pm

PostPosted: 2005-03-14 00:00:26 Post subject:
hmm that doesnt seem to work

heres what i had previously:

Code: Select all
RewriteEngine On
RewriteRule ^site/(.*) /detail.php?siteid=$1 [L]
RewriteRule ^cat/(.*) /index.php?catid=$1 [L]
RewriteRule ^([^.]+)$ /$1.php [L]
Try it this way with a $
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sun Mar 13, 2005 3:36 pm

i think that did the trick

thanks for the quick and accurate help!
Guest
 

Postby Guest » Sun Mar 13, 2005 3:41 pm

is it correct to assume now i can pretty much delete any ".php" references in my code?
Guest
 

Postby Caterham » Sun Mar 13, 2005 4:15 pm

yes, your html-links must point to xy instead of xy.php

The rule will work for all subdirs like /test/register --> test/register.php but there must not be a dot: /test/reg.ister would not work
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 19 guests

cron