PDA

View Full Version : mod rewrite help, .php to .shtml



XeonGX
March 24th, 2007, 15:57
hello,
im trying to make
index.php?page=news
to be
index.shtml?page=news

i think its possible to do with mod rewrite,
can somebody please help?

krakjoe
March 24th, 2007, 16:06
RewriteEngine On
RewriteRule ([a-zA-Z0-9_-]+)\.shtml $1.php


give that a shot been a while since I used rewrite

Decker
March 24th, 2007, 17:05
Joe you constantly krak me up, why don't you control a small country by now? :)

themoose
March 24th, 2007, 17:21
.phtml works on most servers by default FYI. Nice alternative to .php.

krakjoe
March 24th, 2007, 18:51
Joe you constantly krak me up, why don't you control a small country by now? :)

I forgot to send in the forms ...... :angel:

XeonGX
March 24th, 2007, 22:14
thanks :)

now im looking for something search engine friendly.

for example
site.com/index.php?page=folder/file
to
site.com/folder/file.html

is it possible?

krakjoe
March 25th, 2007, 03:28
RewriteEngine On
#Requested :
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?page=$1/$2


^^That would do what you asked for, IMO it's not a great way to do things, send me a link to the site you're on about and I'll write a proper htaccess for it, the rules below would turn fws into an se friendly environment, you'll notice the rules take on a slightly more efficient format ( ^forum/([0-9]+)/?$ ) so that rewrite knows when to do what, with the rule above keeping control over the rest of the sections on your site will be near on impossible.



RewriteEngine On
#Forumdisplay section
RewriteRule ^forum/([0-9]+)/?$ /forums/forumdisplay.php?f=$1
# Showthread section
RewriteRule ^thread/([0-9]+)/?$ /forums/showthread.php?p=$1
RewriteRule ^thread/([0-9]+)/([0-9]+)/?$ /forums/showthread.php?p=$1#post$2


My suggestion for your rule would be


RewriteEngine On
# Suggested :
RewriteRule ^browse/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?page=$1/$2


Hope that helps.