Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by intangiblemedia
at 2024-08-13 03:53:39
Point:500 Replies:4 POST_ID:828742USER_ID:11650
Topic:
Apache Web Server;PHP Scripting Language;Regular Expressions
Hi,
I want to add a line to our .htaccess file - before we had pagination on our product lists, but now we are using ajax.
So before it's like:
ANYTHINGBEFORETHESLASH/this-category.html?p=2
(p can be equal to 0,1,2,3,4,5,6,7,8,9,10......20)
and I wish it to 301 permanent redirect to
/this-category.html
So in essence, remove the ?p=2 and deliver it to the same URL without the ?p=2
What is the expression I need to use?
thanks!
I want to add a line to our .htaccess file - before we had pagination on our product lists, but now we are using ajax.
So before it's like:
ANYTHINGBEFORETHESLASH/this-category.html?p=2
(p can be equal to 0,1,2,3,4,5,6,7,8,9,10......20)
and I wish it to 301 permanent redirect to
/this-category.html
So in essence, remove the ?p=2 and deliver it to the same URL without the ?p=2
What is the expression I need to use?
thanks!
Accepted Solution
Expert: Terry Woods replied at 2024-08-13 21:40:04
167 points GOOD
I'm not that hot at Apache settings, but I can help with regular expressions. This change to @QuinnDex's solution might work for you:
RedirectMatch 302 ^([^.]+.html)?p=([^.]+)$ http://yoursite.com/$1
If so, be sure to share the points with him!
RedirectMatch 302 ^([^.]+.html)?p=([^.]+)$ http://yoursite.com/$1
If so, be sure to share the points with him!
Author: intangiblemedia replied at 2024-08-13 04:28:48
Thanks guys -
I should point out that "this-category.html" is just an example - what I really want is for it to take is
After slash /anythingbeforethisnextdot.html
I have over 200 categories - making individual rules with each URL would be cumbersome.
thanks
I should point out that "this-category.html" is just an example - what I really want is for it to take is
After slash /anythingbeforethisnextdot.html
I have over 200 categories - making individual rules with each URL would be cumbersome.
thanks
Assisted Solution
Expert: QuinnDex replied at 2024-08-13 04:26:11
166 points GOOD
change the 302 to 301 once you have determined its working as you want it, 302 is temporary, 30 1 is permanent, and you will have to restart your browser each time you try and view it as you browser wont request anything from a page marked as 301
RedirectMatch 302 ^/this-category.html?p=([^.]+)$ http://ANYTHINGBEFORETHESLASH/this-category.html 1:
Assisted Solution
Expert: duncanb7 replied at 2024-08-13 04:18:38
167 points GOOD
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*yoursite.com/this-category.html?p=$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/this-category.html/$1 [R=301,L]
It might work after you change yoursite.com to your site
RewriteCond %{HTTP_HOST} ^.*yoursite.com/this-category.html?p=$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/this-category.html/$1 [R=301,L]
It might work after you change yoursite.com to your site