Need help using mod rewrite.

New to mod_rewrite? This is a good place to start.

Need help using mod rewrite.

Postby shadowclash1 » Wed Jun 03, 2009 8:42 pm

Hey! Well I have a problem...
I have a site and this is the current format

www.renta.co.nz/questiondetail.php?questionid=44
Now the questionid changes (44) depending on the question....

I need to change it so my domain looks like this:
www.renta.co.nz/problem/44
OR
www.renta.co.nz/44

I want to replace the work question with problem OR remove the word question completely.
I searched up how to do this and I came to this helpful site :)

Can anyone please give me a specific code specific to my website (currently offline) which I can just straight copy and paste into a .htaccess file.
All help will be appreciated. Thanks:-)
shadowclash1
 
Posts: 3
Joined: Mon Jun 01, 2009 10:38 pm

Postby huyhoa » Wed Jun 03, 2009 11:26 pm

I'm not pro but you should try this:

Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9_]+)/?$ /questiondetail.php?questionid=$1 [NC]



Tell me if it doesnot work
huyhoa
 
Posts: 35
Joined: Tue Nov 28, 2006 2:25 am

Still need help

Postby shadowclash1 » Thu Jun 04, 2009 1:20 am

Thanks that helped but, is there anyway to easily replace my existing links to automatically go to the new page???
I have alot of files and do not want to re-code the whole thing again.

As in when you put the mouse over the link it directly says
www.renta.co.nz/44
not
www.renta.co.nz/questiondetail.php?questionid=44

Thanks again ;D
shadowclash1
 
Posts: 3
Joined: Mon Jun 01, 2009 10:38 pm

Re: Still need help

Postby huyhoa » Thu Jun 04, 2009 8:42 am

shadowclash1 wrote:Thanks that helped but, is there anyway to easily replace my existing links to automatically go to the new page???
I have alot of files and do not want to re-code the whole thing again.

As in when you put the mouse over the link it directly says
www.renta.co.nz/44
not
www.renta.co.nz/questiondetail.php?questionid=44

Thanks again ;D


I think you much edit it in code, mod rewrite cannot do it automatic.
huyhoa
 
Posts: 35
Joined: Tue Nov 28, 2006 2:25 am

Postby richardk » Thu Jun 04, 2009 1:32 pm

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([0-9]+)/?$ /questiondetail.php?questionid=$1 [QSA,L]

so it will only match numbers.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 95 guests

cron