I'd like to do a rewrite-rule at htaccess. The following URL should be rewrited:
http://www.website.com/folder/subfolder/subsub/product-p00000
I'd like to make a rewrite-URL that recognizes the "-p" and then a numeric value. How do I make this rule? I have the following, but not sure how to add the numeric value to it:
RewriteRule ^(.*)/(.*)/(.*)/(.*)-p(.*)/?$ /file.php?folder=$1&subfolder=$2&subsub=$3&product=$4&id=$5
However, in the case of the following URL this goes wrong ofcourse:
http://www.website.com/folder/subfolder/subsub/product-product
How do I add the condition that the URL should end on "-p" followed by a numeric value?
Related
I have the following 2 links, Please some one help me
I want to redirect this page http://www.mywebsite.co.uk/category-of-mobile/any-words/?id=smob_qs&fromDate=&parts=
to another page http://www.mywebsite.co.uk/category-of-mobile/any-words/smob_qs
Note:
smob_qs key is the value of the first query string
For category-of-mobile keyword is fixed
For any-words keyword is dynamic [only characters letters a-z or A-Z]
For query string must removed second and third parameter
Must keep the first query string but only value. Example like smob_qs
So i need http://www.mywebsite.co.uk/category-of-mobile/any-words/smob_qs Url
Please help me using htaccess
I am trying to convert 'http://city.example.com' to 'http://www.example.com/city' in an Excel sheet.
I have tried a multi-step approach to first TRIM or SUBSTITUTE the prefix then the suffix, but I'm in over my head.
Any help would be greatly appreciated. Thanks in advance!
Do heed the comment regarding formulating a proper question and posting what you've tried and what is going wrong.
Either way, assuming your domains are in column A and there is only a single subdomain:
=SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")&MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2))
Breaking it down into pieces:
FIND("//",A1,1)+2 will return the index of the start of the subdomain.
FIND(".",A1,1) will return the index of the first period, the end of the subdomain.
As such, the string from the start of the subdomain to the period will be the subdomain - since we're getting index's back we have to subtract them to get our MID length - FIND(".",A1,1)-(FIND("//",A1,1)+2)
Chaining those together, we can say we want to substitute whatever is from the // to the first period with www. - SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")
This now leaves us with the subdomain replaced with www, so we just need to append the subdomain now, which we already know how to get - it's the mid formula we just used:
MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)
As such, we concatenate our two formulas together to get the result.
For some reason I have to subtract a number from $1 here, which will be a digit:
RewriteRule ^categories\/([0-9]+)\/(.*)?$ /at.php?-category_$1 [L,NC]
I want to pass $1-4 into category number here. For example, if URL is:
http://localhost/categories/12/xyz
Category id will be 12-4 which will be 8.
Can we do some simple plus minus operations here?
Ive got a list of urls, Im trying to check if for each cell the the url contains .com OR .co.uk and if it does put the text TRUE into the result cell, this way i can filter the result column to find all the cells that contain .com or .co.uk as the top level domain of the url.
At the moment im trying to use
=IF(D2=".com","TRUE", "FALSE")
The issue Im having is to do with the first argument to check if the url contains .com OR .co.uk, at the moment its just checking if the whole url == .com.
You can use FIND:
=OR(ISNUMBER(FIND(".com",A1)),ISNUMBER(FIND(".co.uk",A1)))
Use ISNUMBER to swallow any #VALUE! errors.
Note that FIND does a case-sensitive search. For a case-insensitive search, use SEARCH instead.
You could also use regexextract with an or "|" to give it both variations:
=if(isna(REGEXEXTRACT(A1,"\.com|\.co\.uk")),,true)
I'm trying to detect numbers in a URL greater than 9 at the end of my URL. For example:
"...com/celtic-jewelry/traditional/10"
I've a work around in my .htaccess using two seperate lines that work as a combination (the 1st line detecting number less than 10, the 2nd detecting numbers over 9, but I'm wondering what the correct method is? My .htaccess is below, thanks!
RewriteRule ^celtic-jewelry/([a-z-'/]+)/([0-9])$ /product.php?flags=$1&page=$2 [L]
RewriteRule ^celtic-jewelry/([a-z-'/]+)/(.[0-9])$ /product.php?flags=$1&page=$2 [L]
If I got it right:
RewriteRule ^celtic-jewelry/([a-z-'/]+)/([1-9][0-9]+)$ product.php?flags=$1&page=$2 [L]
How about just the following single rule, to replace your two rules:
RewriteRule ^celtic-jewelry/([a-z'/-]+)/([0-9]+)$ /product.php?flags=$1&page=$2 [L]
Here [0-9]+ means "one or more digits 0-9". So that catches all numbers of 1, 2, or more digits, in just one rule. Although the title of your question is about numbers greater than 9, the context makes it clear that you're trying to capture all numbers, whether 1, 2, or more digits.
Also, note that in [a-z'/-]+, I moved the second - to the end of the brackets. You wrote it as [a-z-'/]+, but the problem there is that the second - could act as a range operator, while I think your intent was to use it as a literal dash character. To keep the - from acting as a range operator, you have to either put it first or last within the brackets, or else escape it with a backslash (\-).