I generate URLs using mcrypt in PHP and the results often contain percent signs like this: https://example.com/J6CVxO7lzS0KSimTgmpY4LcqDflQUWkmihBxBrXh%2FdnP8W8vUfFWbq3faAURi098
The problem is that HTACCESS doesn't like the percent sign so none of my rewrites match the URI; I have tried "\w", "." and [a-zA-z0-9\%]).
Is there a way to take everything after the domain name and redirect to index.php?id={EVERYTHING AFTER "example.com/"}
Any help would be greatly appreciated.
Related
I have old urls which contain consecutive numbers I like to redirect via htaccess, for example:
(im not allowed to post links yet)
www.example.com/just/another/path2/name-789-e-11-2.html
www.example.com/its/another/path3/name-789-e-11-5.html
On the new system the appended numbers dont exist anymore:
www.example.com/just/another/path2/name-789-e-11.html
www.example.com/its/another/path3/name-789-e-11.html
So the filename in the different paths is now the same, without the appended consecutive numbers.
Does anybody have a solution for that? I tried different but none of them worked.
Any help would be greatly appreciated.
You can use this redirect rule as first rule in your site root .htaccess:
RedirectMatch 301 ^/(.+\d+)-\d+\.html$ /$1.html
Can anybody advise how I can rewrite the following URL:
www.mydomain.com/products.php?product=product-name
At the moment, it works fine (I use $_GET to grab the unique product name and use it on my page) but I would like to be able to use the following URL format to get the same outcome:
www.mydomain.com/products/product-name
I've seen a few similar examples on here but cannot get them to work with my situation.
This is how your .htaccess will look like,
RewriteEngine On
RewriteRule ^products/([A-Za-z0-9-]+) /products.php?product=$1 [NC,L]
RewriteEngine On this is used to turn on the rewrite engine.
^products/([A-Za-z0-9-]+) matches the URL like (www.mydomain.com/products.php?product=product-name) where product name can be one or more of any combination of letters, numbers and hyphens.
And use that combination of letters in /products.php?product=$1 where $1 denotes the Product name.
I am looking to rewrite approximately 5000 old product urls and I'm thinking that a rewrite rule in my .haccess file might do the trick, although creating this is too advanced for me.
Old Url Example:
Please keep in mind that the "68p4963" is randomly generated.
http://www.example.com/store/pc/Strapless-Monarch-Butterfly-Fairy-Wings-68p4963.htm
Preferred Url example:
This should now have a 301 redirect without the "www." and with the product name converted to lowercase.
http://example.com/products/strapless-monarch-butterfly-fairy-wings
Thank you.
I'm using links like that:
find.php?id=1&n=2#loc
I want to my links look like:
but i dont know how to change htaccess and when/where use # to link some place in the page #loc
htaccess:
RewriteRule ^(.*),(.*),(.*)$ $3.php?id=$2&n=$1 [L,NC,NS,NE]
Help lease
The #loc part of the URL is never sent to the server, so there's no way for you to match against it in your htaccess file. Anything starting from the # in the URL is called a fragment and it's used by the browser, the server doesn't know it's even there.
I am completely lost and all my searching on Google and winthin the board did not get me to a working solution.
Setup
Apache-webserver
htdocs are located: xampp/htdocs
my Joomla site is located: xampp/htdocs/example.com/www
Two kinds of URI as possible on our homepage:
URI end with a number (8 digits; e.g.: www.example.com/[any page/12345678)
URI does not end with a number (e.g.: www.example.com/[any page])
If the URI ends with a number do the following
Read the number from the URI and place it in a cookie
Redirect the request to the same URI except for the number
(e.g.: www.example.com/[any page])
If the URI does not end with a number do the following
Open the page as requested (e.g.: www.example.com/[any page])
I was hoping that this was not too difficult to do but I am completely lost. Would you please as to give me a little help. Please do include a statement to RewriteBase as well because it is giving me a hard time, too.
RewriteEngine On
RewriteRule (.*)/([0-9]{8})$ /$1 [R=301,CO=cookieName:$2:.example.com:1440:/]
take a look at http://httpd.apache.org/docs/current/rewrite/flags.html#flag_co for more information about cookie flag