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

Timestamp issue into Cassadnra table
How do you debug Guzzle 6 with a debugger?
get_headers Connection time out
Remove number formatting from a string
PHP: session error [duplicate]
display image from a PHP for loop
Laravel 5.3 can't paginate model with derived field
RedirectResponse in Symfony
Insert into sql with buttonclick [duplicate]
Laravel #extends and #include
echo query return data from array
Issue with refreshing div with ajax [duplicate]
Correct File/Dir Permissions for Wordpress on CentOS
DOMPDF replaces “≤” by “?”
Creating a custom top menu in magento 1.9.2
Get image from local path in php

Categories

HOME
entity-framework
artificial-intelligence
mod-rewrite
lambda
keyboard
freeradius
bokeh
add-on
compilation
plaid
visual-studio-2010
semantic-web
yql
lvm
cypher
iptables
clone
javafx-8
graphql-js
wine
locationmanager
getopenfilename
bootstrap-switch
grocery-crud
spring-jpa
twisted
hidden
rpmbuild
cocos2d-android
string-formatting
anova
hdl
neo4j.rb
gollum-wiki
mod-wsgi
managed-c++
python-appium
jsonresult
memory-fences
advanced-filter
nest
testlink
aurelia-http-client
sspi
export-to-pdf
google-prediction
transparency
reverse-dns
flume-twitter
swift2.3
.net-micro-framework
photoswipe
sonatype
sigsegv
skip-lists
algebra
case-when
emacs25
hmmlearn
openerp-6
gawk
google-identity-toolkit
visual-studio-monaco
jenkins-workflow
groovyfx
node.js-connect
qpixmap
node-glob
processor
deeplink
dsa
hmisc
wlanapi
uitest
green-threads
algebraixlib
explain
qt5.4
igor
quantify
screwturn
prism.js
rails-api
thruway
mousemotionlistener
sql-view
stty
django-facebook
dibs
cmath
ckeditor.net
lynx
xcode4.5
fbml
vows
database-deadlocks
kernel32
simile
qcar-sdk
mygeneration
ios-4.2
tessellation
3-tier
odac
facebook-fbml
bucket
datagridcolumn

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