Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Need Help With Creating Wild Card Routes
I need to create a route so that example.com/cache/Sitemaps/anything.xml is shortened to example.com/anything.xml.
Can anyone help? Thanks!
0
Best Answer
-
LeeH ✭
This is the kind of thing that you should try to do with your web server instead of at the application layer if possible—a redirect or rewrite by the web server will always be faster and use fewer resources than pushing something up and down the php stack! x00's advice to use a rewrite rule in one of your .htaccess files (or in your vhost config) is right on.
0
Answers
Htaccess rewrite
http://www.myseotool.com/free-seo-tools/htaccess-url-rewrite-generator.php
There was an error rendering this rich post.
@422 : Can you please explain? I am not really well versed with .htaccess stuff.
Here's the thing: example.com/cache/Sitemaps/anything.xml should be shortened to example.com/anything.xml, but example.com/anything.xml itself isn't supposed to redirected anywhere.
If you know how I can achieve that using Htaccess rewrite, please do share. Thanks!
@422 : Thanks for the tool, but it doesn't seem to do wildcard redirects. Maybe I wasn't clear.
example.com/anything.xml does not exist!
I want any file in example.com/cache/Sitemaps/* to be shorted to (not redirected) example.com/*
For example, I should be able to access example.com/cache/Sitemaps/anything.xml from example.com/anything.xml as if the file (anything.xml) is actually present at example.com/.
Is that possible? I hope I am clear this time.
U can do a rewrite so the clickable uri appears like a destination uri
Eg. We have a fille called twats.php
We can use rewrite to make it look like a folder.
Is that what u mean?
There was an error rendering this rich post.
@422 : No, I mean a wildcard redirect. That is... one rewrite rule that creates aliases for all files in a directory. For example:
example.com/cache/Sitemaps/file1.xml → example.com/file1.xml
example.com/cache/Sitemaps/file2.xml → example.com/file2.xml
example.com/cache/Sitemaps/file3.xml → example.com/file3.xml and so on...
That's what I meant by a wildcard rewrite rule. Do you know to do it? (It uses something like $1, and stuff that doesn't make sense to me.)
x00 will know, he is at one with that shizznit
There was an error rendering this rich post.
@x00 : Need some help when you are here. Thanks!
If you look at my post on sitemaps question I provide the answer to this, I used vanilla routes but you can also use .htacess
RewriteRule sitemap\.([^\.]+)\.xml$ cache/Sitemaps/sitemap.$1.xml
the ^ in the square brackets means negative so anything that is not a . (dot) and more than one (+) followed by .xml. This is a typical but not the only way of doing wild card. As regexp is quite specific using negative is a way of caching a lot of characters.
grep is your friend.
@x00 : Can you please provide a link to that post? Thanks.
can't you search for it? I provided exactly the answer to this question, look at the questions off the sitemaps plugin and you shall find it.
It get really tedious if I have to dig this stuff up myself.
grep is your friend.
@x00 : you said, "If you look at my post on sitemaps question I provide the answer to this, I used vanilla routes but you can also use .htacess" So I thought, you provided an alternative answer elsewhere.
I have been searching on (& trying to fix) this issue since morning. Looks like my search terms did not match the question you answered. It's not always easy to 'search' when you don't know the exact search terms to query for.
I try my best on an issue before I ask buddy.
grep is your friend.
Damn! It didn't strike my head that I could actually follow the 'Sitemaps' tag. Thanks for pointing me in the right direction.
EDIT: I missed the questions on that page because the page is broken and the questions are quite far below. lol!
Finally found it: http://vanillaforums.org/discussion/17008/sitemaps-relatively-easy-to-setup-follow-these-instructions/p1
This is the kind of thing that you should try to do with your web server instead of at the application layer if possible—a redirect or rewrite by the web server will always be faster and use fewer resources than pushing something up and down the php stack! x00's advice to use a rewrite rule in one of your .htaccess files (or in your vhost config) is right on.
@LeeH : You are right. I did just that. But a choice is always good. So, I was checking both.
Cough. Didnt i mention this lol
There was an error rendering this rich post.
@422 : Isn't the addon's page broken for you? http://vanillaforums.org/addon/sitemaps-plugin
The questions have been pushed quite far below, which made me think there were no questions at all. I should have checked properly, nevertheless. :P