Forum Moderators: phranque
I have 800 pages and some sub pages. I want to change this sub pages:
xxxx.com/search/browse.php?pg_which=2&cat=1
to:
xxxx.com/search/browse_1_2.php
Here are my .htaccess:
RewriteEngine on
RewriteRule ^(.*)\/browse_([0-9]+)\.php$ /$1/browse.php?cat=$2 [L]
So what wrong with my .htaccess and what should I do to get the result?
Thanks for your help!
So $1_$3_$2.php should give :
[somesite.com...]
Is that the result you'd wish to get?
The first term in the rule is what you receive from the visitor and what you want them to see in the URL, the second is the actual URI that will be used by the server.
The first line in my example below (RewriteBase /) allows you to omit the mydomain.com/ stuff and start with your variables. You may want to consider leaving out the search/browse stuff and just use something like
[mydomain.com...]
Seems less confusing to me. You can insert the search/browse stuff in the second term of the rule.
Try this ... (haven't tested it, so play with it)
RewriteBase /
RewriteRule ^search/browse_([0-9]+)_([0-9]+)\.php$ search/browse\.php?pg_which=$2&cat=$1 [NC,L]
If you go with the example I mentioned, the rule would be ...
RewriteBase /
RewriteRule ^([0-9]+)/([0-9]+)$ search/browse\.php?pg_which=$2&cat=$1 [NC,L]
Or, if you know the number of digits you will be using, (let's say three), you could use the following ...
For a user sending [yourdomain.com...]
You could say ...
RewriteBase /
RewriteRule ^([0-9]{3})([0-9](3})$ search/browse\.php?pg_which=$2&cat=$1 [NC,L]
where the digit inside the curly braces tells the engine how many times to loop through the characters. In this example, $1 would be 123, and $2 would be 456
Remember that the $1 and $2 variables are numbered by the sequence they are created in the first term. You can use them in any sequence and as many times as you wish, but only on that line (jdmorgan has identified a bug that limits their use after one line).
Welcome to WebmasterWorld!
The discussion in this recent thread [webmasterworld.com] may help you get started.
Jim
RewriteEngine on
RewriteRule ^(.*)\/browse_([0-9]+)\.php$ /$1/browse.php?cat=$2 [L]order allow,deny
deny from 68.184.84.58
deny from 68.184.84.58.
deny from 58.84.184.68
deny from 64.124.85.93
deny from 64.124.85.201
deny from 64.124.85.202
deny from 64.124.85.203
deny from 64.124.85.204
deny from 64.124.85.205
deny from 64.124.85.206
deny from 64.124.85.207
deny from 64.124.85.208
deny from 64.124.85.209
deny from 64.124.85.210
deny from 64.124.85.255
allow from all<Files .htaccess>
order allow,deny
deny from all
</Files>