Rewrite URL Help

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

Rewrite URL Help

Postby BoyBlue » Wed Sep 10, 2003 5:08 pm

I know this is a common question, but can anyone give me advice on setting up a mod-rewrite that strips the URL of characters such as "?" and "=". I have scoured the message board and studied the other examples, but the solution eludes me.

I am trying to convert:

www.mydomain.com/resources/index.php?viewCat=1

to something like:

www.mydomain.com/resources/viewCat1.htm
or
www.mydomain.com/resources/categoryname

Here are the contents of my .htaccess file located in the /resources subdirectory:

RewriteEngine on
RewriteBase /
RewriteRule ^CatID([^.]+).*$ index.php?viewCat=$1
[T=application/x-httpd-php]

CatID is the category ID number from the MySQL database.

I know these repetitious newbie questions can get tiresome, but any advice or direction would be greatly appreciated.

Many thanks!
BoyBlue
 
Posts: 1
Joined: Wed Sep 10, 2003 4:57 pm

Postby pippo » Fri Sep 12, 2003 10:45 am

Hi,

> I am trying to convert:
>
> www.mydomain.com/resources/index.php?viewCat=1
> to something like:
>
> www.mydomain.com/resources/viewCat1.htm
> or
> www.mydomain.com/resources/categoryname
I'll suggest a solution to let what marked in bold works.

/resources/.htaccess
Code: Select all
    RewriteEngine on
    RewriteRule ^viewCat([0-9]+)\.htm$ index.php?viewCat=$1 [L]


so a request for
www.example.com/resources/viewCat1.htm
will be redirected internally to
www.example.com/resources/index.php?viewCat=1



THanks,
:) Mr Andrea
pippo
 
Posts: 6
Joined: Sat Sep 06, 2003 11:27 pm

Postby msolari » Fri Sep 12, 2003 4:17 pm

Thanks Andrea!
msolari
 


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 17 guests

cron