I am hoping that someone can help me locate where this rewrite is coming from (searched all my nginx files and its not there. I'm guessing it's a WP rewrite in includes?) and help me prevent the rewrite from converting my uppercase path letters to lowercase letters.
Example: If you navigate to this image (below) in a browser please notice that the URL is rewritten. This is not a rewrite I created but it works out because users that are hitting my old blog images which are indexed online will need the rewrite to view them. BUT the uppercase letter 'H' is converted to lowercase 'h' so the user will not be able to view it! If you modify the lowercase to an uppercase in the URL string and hit the page you can now see the image.
Can someone please help me solve this issue? I cannot rename all my images by the way. Also I am using nginx and i hear that you are not aloud to remove case sensitivity from nginx like you can with apache.
Nginx includes a method for converting uppercase to lowercase:
rewrite ^ https://$host$request_uri_low;
make sure you config doesn't have this kind of conversion.
Related
Hello I'm not trying to use space or anything like that. all my urls are standard with dash separated words but the characters are in persian so instead of
/%D8%A2%D8%B1%D8%A7%DB%8C%D8%B4%DB%8C
I wanna see
/آرایشی
The links are already saved as the second one but when it shows it on webpage it automatically encodes it.
My CMS can handle getting requests like the second one and auto redirect. I've tried changing config file and some globalization settings but no luck yet.
I am on Wordpress and right now using Yoast Seo Pro which has a redirection section including a Regular Expressions redirects section.
How do I redirect say /mycategory1/page/pagenumberhere/ to
/category/mycategory1/page/pagenumberhere/ ?
So I only need to make one redirect that handles all possible page numbers?
I have tried /mycategory1/page/([0-9]) to /category/mycategory1/page/$1
It looks like it redirects to /category/mycategory1/page/pagenumberhere/ but there is an err_too_many_redirects on the /category/mycategory1/page/pagenumberhere/ with this rule added so I have removed it again.
If you can help with code into the .htaccess instead perhaps I could try that.
Your rule already looks promising.
However, as #starkeen pointed out, the regular expression mycategory1/page/([0-9]) matches every request containing mycategory1/page/ with some trailing number. This is true of category/mycategory1/page/ as well, as it also contains "mycategory1/page".
If you want to match requests starting with mycategory1/page, you must anchor the regular expression at the beginning with ^, see Apache mod_rewrite Introduction - Regex vocabulary
RewriteRule ^mycategory1/page/([0-9]) /category/mycategory1/page/$1 [L]
I using Google Tag Manager and I am trying to setup a rule that will fire ONLY on my sites homepage.
The issue is that I am not certain how to handle all of the URL permutations of the homepage. How can I create a rule that will handle:
"http://" "https://" "http://www." "https://www."
Also, we use Sitecore and support multiple languages, so the homepage url can also display as:
"http://www.mysite.com/en"
I am not sure how to handle the culture identifier that is inserted into the URL path after a visitor has used the navigation on the site.
Is it possible to use the OOTB Google Tag Manager rules to handle this scenario, or will I have to implement a Tag Manager Data Layer?
The following rule would check if it's the homepage:
{{url}} matches RegEx ^https?://(www\.)?mysite\.com/?(index\.html)?$
{{url}} gives the whole address whereas {{url domain}} just gives the domain and {{url path}} just the path (including the initial forward slash).
This matches http and https, with or without www and with or without index.html at the end. It also matches mysite.com/ and mysite.com (without the forward slash at the end). If you want to check for URL permutations at the end of the homepage, you could do something like:
^https?://(www\.)?mysite\.com/?(en|es|fr)?$ etc.
Also, forward slashes do NOT have to be escaped. In fact, escaping forward slashes broke the firing rule in GTM for me...
See http://en.wikipedia.org/wiki/Regular_expression
edit: and if you want to ignore the querystring (which is a good thing to do because most ads add query keys such as utm_source etc. to the url), you can have something like this:
^https?://(www\.)?mysite\.com/?(index\.html)?/?(\?.*)?$
(note the (\?.*)? at the end)
Ok... so after researching the Google Tag Manager Forum, this can be accomplished by making separate url "ends with" rules for your site url and then your site url with a trailing forward slash such as:
rule 1 : url ends with http://mysite.com
rule 2 : url ends with http://mysite.com/
I think it was the trailing slash that was confusing the matter as I was setting up the rules.
This is a super robust way to know it's your home page with either protocol and allow for a backslash all with one line of Regex...
^https?://www.mydomain\.com\/?$
Not sure sure why the initial double backslashes don't have to be escaped, but it works. Would have expected ^https?:\/\/www.mydomain\.com\/?$ Maybe someone else knows that :)
I have a Wordpress based website that I scrap using wget.
I have articles under the form
http://mydomain.com/2011/01/
once scraped becomes
http://mydomain.com/2011/01.html
I found out that when I enter
http://mydomain.com/2011/01/
in the navigator, URL gets changed to
http://mydomain.com/2011/01
which is why, I think, it is considered as a file when I call wget.
I would be very grateful if someone has some clue on how to address this.
I finally managed to get to the result I wanted, in this way:
changing my permalink structure from
/%year%/%monthnum%/%postname%.html
to
/%year%/%monthnum%/%postname%/
I'm using the iis7 URL Rewrite module and it's working fine, except for two things. Being new to this, I might be missing something obvious.
1) My URL gets converted from
www.mysite.com/search.aspx?fName=John&sName=Smith
to www.mysite.com/John/Smith. This works fine, but if I add a trailing / , a few images on the site disappear, wheras a few don't. (They're all in the same location). However, the search results are fine.
2) Is it possible to make cerain querystrings optional? Server side, this is implemented (i.e. if nothing is entered, then assume a default value). But how would this work with the URL rewrite module?
e.g. www.mysite.com/John would search for John and use a default value for the sName parameter.
Thanks for any help.
I can't help with the optional query string parameters I'm afraid, but the images one should be fairly easy:
How are you declaring the image paths in your markup? If you are using relative paths (i.e. src="../Images/someimage.png" then adding a trailing slash to the URL is telling the browser that the /Images/ folder is under the folder /John/ instead of being at the root of the site.
If you are using HTML <img /> tags, you should prefer a virtual path: src="/Images/someimage.png" - this tells the browser to request the image path from the root of your site.
If your application isn't running in the root of the site, you can also use the ResolveUrl method that is part of the page and control object tree, this allows you to pass in a virtual path of the form ~/Images/someimage.png and the framework will work out what the correct path should be.