php


Regex to append a variable to URLs


I have a regex right now on a WordPress site using Redirection plugin:
Source URL:
^/video/(.+)
Target URL:
/video/$1
And that's working fine. Now, I need to add ?filter=views to the end of the Target URL, but I can't seem to find a way to do it.
Desired redirection would be:
site.com/video/video-category-name to site.com/video/video-category-name?filter=views
Adding /video/$1?filter=views as Target URL adds multiple ?filter=views when I just need the variable added once.
Any one that can help me out? Thanks!
You should exclude multiple redirections by using
Source URL: ^/video/([^?]+)
Target URL: /video/$1?filter=views
Explanation
if Source URL is ^/video/(.+) then (.+) will match anything after /video/ including after the first redirection :
/test match .+ => REDIRECT TO /video/test?filter=views
/test?filter=views match .+ => REDIRECT TO /video/test?filter=views?filter=views
... etc.
If you allow any character except ? after /video/ then redirection will stop immediately because /video/$1?filter=views won't match Source URL anymore

Related Links

How can I change this Html Form to Yii framework
How to get log() of a very big number (PHP)?
command line data curl convert to array
Display content based on date and time
How to give a custom name to the PDF being downloaded using FPDF library?
DNS with subdomain doesn't work properly
SMPP: the UDH (User Data Header) appears in the body of sms
Compare 2 arrays and retrieve the differences using PHP
wordpress making a static and dynamic link
for each if true fetch mysqli result
PHP, CodeIgniter, MySQL - SELECT - overloading database
How do I enable member login to a specific directory including sub-directories in wordpress
Uploading mp4 files using PHP
Move files in php with move_uploaded_file [closed]
Count Items in Array PHP
Radio button with same id in Laravel 4.1.x

Categories

HOME
jboss
ionic2
powerbi
libgdx
generics
shinyapps
windows-10
tcsh
gallery
elk-stack
log4j2
solution
sap-fiori
tiff
freertos
powermock
sonata
orange-api
sonicwall
cocos2d-android
gmp
parceler
akka-persistence
multi-dimensional-scaling
spring-annotations
es6-modules
cmis
redgate
unification
rdp
ejml
dagger
permission-denied
doctrine-extensions
react-intl
cloudwatch
icecast
node-apn
skip-lists
wikimapia
apache-modules
prefetch
bpms
metabase
always-on-top
raw-sockets
adp
codecharge
preferenceactivity
onepage-checkout
ioctl
grinder
srv-record
search-form
supersocket.net
sequence-sql
com0com
actionpack
web-api
android-audiomanager
htmltidy
webmethod
aho-corasick
coding-efficiency
network-printers
fileshare
refit
pageviews
preorder
cidr
accountmanager
armv6
frontbase
yii-booster
quickgraph
html-frames
cgrectmake
workflow-manager-1.x
websphere-6.1
winsxs
kohana-auth
fragment-identifier
mongrel
fgetc
rational-unified-process
powergui
main-method
tacit-programming
autobench

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App