NameSilo

Htaccess - What have I done Wrong in my code?

Spaceship Spaceship
Watch

ridesign1

Established Member
Impact
7
I have a page http://www.site.com/new

1)I want to redirect http://www.site.com/new/1/
to : http://www.site.com/new?pg=1

2)And redirect http://www.site.com/new/cat/2/
to : http://www.site.com/new?c=cat&pg=2

3)And redirect http://www.site.com/new/cat/
to : http://www.site.com/new?c=cat

I have attempted the following 1 and 2 work but 3 does not work:
"c" will always be small letters and "pg" will be between 1-5.


Code:
RewriteRule ^new/([a-z])/$ /new/?c=$1 [L]
RewriteRule ^new/(.*)/([0-9])/$ /new/?c=$1&pg=$2 [L]
RewriteRule ^new/([0-9])/$ /new/?pg=$1 [L]
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
I don't know much about .htaccess, but is that your entire .htaccess file? Don't forget to turn RewriteEngine On.
 
0
•••
no sorry , that is just a section of it.
yes have got that to turn on rewrite :)
 
0
•••
You want:

Code:
RewriteRule ^new/([a-z][COLOR="Red"]+[/COLOR])/$ /new/?c=$1 [L]
 
0
•••
what does the + do?
do i need to add the + for ([0-9]+)?

Should this work?

RewriteRule ^new/([a-z]+)/([0-9]+)/$ /new/?c=$1&pg=$2 [L]
 
0
•••
The "+" mean match one or more of the previous element (in this case one or more letters). Without the "+" the pattern will only match a single letter between the slashes. With the "+" it will match one or more letters between the slashes. You don't need it after the [0-9] since you only expect a single digit.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back