noob query - multiple extensions rule

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

noob query - multiple extensions rule

Postby exmadyn » Fri Sep 04, 2009 8:55 am

i'm new to mod_rewrite and i can't figure how to combine this rule...

need help on this...

this is my current extensions:
category.php?page=professional
category.php?page=diving
to
collections/professional
collections/diving

also,
company.php?page=about
company.php?page=message
to
company/about
company/message

and,
product.php?item=6921&category=sea
product.php?item=6971&category=military
to
sea/itemname
military/itemname
exmadyn
 
Posts: 3
Joined: Fri Sep 04, 2009 8:20 am

Postby richardk » Sat Sep 05, 2009 8:11 am

product.php?item=6921&category=sea
product.php?item=6971&category=military
to
sea/itemname
military/itemname

itemname or itemid? For itemname see FAQ: How to change a numeric ID into a name/title.

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

# /collections/professional --> /category.php?page=professional
RewriteRule ^collections/([^/]+)/?$ /category.php?page=$1 [QSA,L]

# /company/about --> /company.php?page=about
RewriteRule ^company/([^/]+)/?$ /company.php?page=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

test site

Postby exmadyn » Sat Sep 05, 2009 11:20 pm

i created a test site but it's not working:

www.testurl.com/company.php?page=about

however, this test code is working:
Code: Select all
RewriteRule modrewrite http://www.modrewrite.com/? [NC,R,L]

www.testurl.com/modrewrite is redirected to www.modrewrite.com/

am i missing something?

here's the code:
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

# /collections/professional --> /category.php?page=professional
RewriteRule ^collections/([^/]+)/?$ /category.php?page=$1 [QSA,L]

# /company/about --> /company.php?page=about
RewriteRule ^company/([^/]+)/?$ /company.php?page=$1 [QSA,L]

RewriteRule modrewrite http://www.modrewrite.com/? [NC,R,L]


i inserted the modewrite redirection for testing...
Last edited by exmadyn on Sun Sep 06, 2009 6:13 pm, edited 1 time in total.
exmadyn
 
Posts: 3
Joined: Fri Sep 04, 2009 8:20 am

Postby richardk » Sun Sep 06, 2009 3:42 pm

Go to /company/about, it is working. You must edit your script to output the new links.

The images/css problem: FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby exmadyn » Sun Sep 06, 2009 6:11 pm

thanks alot...

your the best...
exmadyn
 
Posts: 3
Joined: Fri Sep 04, 2009 8:20 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 28 guests

cron