I'm trying to cut the parameter, leaving just its value using htaccess. Unfortunately it doesn't work. It should look like this:
localhost/?url=abc --> localhost/abc
Please help :)
Related
I am a little lost. I tried searching this site and the web at large, but I couldn't seem to find exactly what I need. So please forgive me if this has been answered before, I really tried to find it.
I have … inherited a .htaccess file with quite a lot of 301 redirects in the
Redirect 301 /shorthand /actual-link/actual-file.php
syntax (with a RewriteEngine On line somewhere high up in the file). I don't know exactly much about redirects, but that seems pretty straightforward to me. It just sits there and sometimes new shorthand links get added. There is some non-www to www, and http to https kind of stuff at the top, that's it.
Now the structure of the site changes, and two similar pages that process query parameters get consolidated into one. Basically there is
Old page: /path/subpath/index.php?some=query¶meter=or&other
New page: /other-path/file.php?added=parameter&some=query¶meter=or&other
I can't predict what parameters exactly will be part of the URL, I just have to take everything starting from the ? and append it to the new URL, that already has to include an added parameter, so everything after the ? follows ?added=parameter& .
I suppose that is not exactly hard, but alas, I lack the experience. And all I could find was something like "Take this specific defined query parameter you already know and set it as a path name" or vice versa, and I couldn't get that to work for my problem.
Is there a solution compatible with the syntax used elsewhere in the file? Or does that matter at all? Can I combine Redirect 301 … lines with RewriteCond … RewriteRule … commands? Does %{QUERY_STRING} help me somehow? If so, how can I figure out the correct syntax?
I would really appreciate if someone could point me in the right direction.
Many thanks in advance!
I'm a complete rewrite newbie and I'm lost. We need to pass a URL and append it to the end of another URL. For example: If I go to www.site1.com/x_x_x/xxx/xxxxxxxxx/file.pdf I need it to be passed and appended to a 2nd URL. It should look like this: www.site2.com/?remoteurl=www.site1.com/x_x_x/xxx/xxxxxxxxx/file.pdf
This is what I have so far: RewriteRule /([a-z0-9-]+)([a-z0-9-]+)([a-z0-9-]+)/([0-9]{3})/([0-9]{9})/([a-z0-9-]+)([a-z0-9-]+)([a-z0-9-]+)[A-Z]{2}.pdf$ https://site2.com/?remoteUrl=http://site1.com/(missing code goes here?) [QSA,NC,R]
The first part works perfectly. Any file I go to will match correctly and get forwarded to the second URL. Obviously I'm missing the crucial part of appending. I feel like an idiot for not being able to figure this out. I've tried a few stuff I found online but nothing is working for me.
I'm not sure if that's even the correct way of doing this.
You can use this :
RewriteEngine on
RewriteRule ^ http://example2.com?remoteurl=%{HTTP_HOST}%{REQUEST_URI} [L,R,NE]
I have been trying several different combinations for resolving the following URL. I just can't get it to redirect where I need it to.
https://www.oldsite.com/http://www.oldsite.com/
needs to redirect to
https://www.newsite.com/
I can't find the right combination to work.
Any help is greatly appreciated.
I am wondering if this is possible to do with an .htaccess rule.
My beginning url:
http://cmfi.org/wherewework/missionary/?missionary=ttaho%2C
What I want to end up with:
http://cmfi.org/wherewework/missionary/ttaho
The ttaho will change according to the page.
Thanks for any input.
Don't think I was asking anyone to code this for me...Just asking if it was possible. I have tried a few things and couldn't get them to work. The %2c is an encoded part of the url that is added from the plugin I was using.
I will figure it out. No worries.
I need to create a series of redirects for personalized urls. They need to go from a directory on my server to a more complex url on another which includes a query string based on the original url. Here is an example:
I would like to rewrite from this:
http://www.mywebsite.com/TestDirectory/John.Doe
to this:
http://their.server.com/adifferentdirectoryname/page.aspx?u=John.Doe&s=lorem&dm=purl
There will be hundreds of these personalized urls I will send out, so I need the solution to account for that so that I don't have to write this for hundreds of names.
Any help is greatly appreciated. Much Thanks!
I think you want something like this:
RewriteRule ^TestDirectory/(\w+\.\w+)$ foo.aspx?u=$1 [R]
The regex \w+\.\w+ matches a word, a dot, and another word. The $1 is replaced with the captured string from the regex. The [R] means to actually redirect the user.
These rules are tough to get just right so I recommend reading through some examples.