htaccess Redirecting or Rewriting to a form results page with variables intact - .htaccess

I am building a website which calls for a page selector on product search results, the page selector currently adds a forward slash and a number (representing the page) to the end of the current URL.
e.g. If I am browsing Washing Machines on "/laundry/Washing-Machines" and I click page 2 on the selector it takes me to "/laundry/Washing-Machines/2" and page 2 loads, this is working fine.
Now, the problem I am having...
I have a form in the sidebar where the user can filter Range Cooker search results by brand, fuel type, size and colour. The form gathers the products from the database that meet the search criteria, and displays the results along side the page selector.
If I leave the form values as default and submit the form I am presented with the results on "/cooking/Range-Cookers/Search?brand=0&type=0&size=0&colour=0" but when I click page 2 on the selector I am taken to "cooking/Range-Cookers/2" which presents me with a 404. If I add "&page=2" to the end of the original URL I am presented with page 2.
Since the page selector is a php include and works fine for every product except the results from my Range Cooker form, I would rather find a solution that leaves the selector php intact.
Is there any way I can add a redirect to .htaccess which would take a link from my page selector e.g. "cooking/Range-Cookers/5" and correctly apply it to the current URL with all form variables intact e.g. "cooking/Range-Cookers/Search?brand=1&type=2&size=0&colour=0&page=5"?
I have experience in HTML, CSS and PHP, but I am new to editing .htaccess and would appreciate any insight into how I can accomplish this. Thanks.

You cannot do this with .htaccess, because the information is not available, when the request hits Apache, or .htaccess for that matter.
When you click the link for page 2, the client requests the URL in the associated href attribute. It doesn't provide any other information available on the current page. If you want this information transmitted, you must modify the link for page 2 from
cooking/Range-Cookers/2
to
cooking/Range-Cookers/Search?brand=1&type=2&size=0&colour=0&page=2
when you deliver the page to the client. Same goes for any other information you need for following pages.

Related

How to fetch website links when they're not numerically ordered

Using beautifulsoup it's easy to fetch URLs that follow a certain numeric order. However how do I fetch URL links when it's organized otherwise such as https://mongolia.mid.ru/en_US/novosti where it has articles like
https://mongolia.mid.ru/en_US/novosti/-/asset_publisher/hfCjAfLBKGW0/content/24-avgusta-sostoalas-vstreca-crezvycajnogo-i-polnomocnogo-posla-rossijskoj-federacii-v-mongolii-i-k-azizova-s-ministrom-energetiki-mongolii-n-tavinbeh?inheritRedirect=false&redirect=https%3A%2F%2Fmongolia.mid.ru%3A443%2Fen_US%2Fnovosti%3Fp_p_id%3D101_INSTANCE_hfCjAfLBKGW0%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1?
Websites such as these are weird because once you first open the link, you have » Бусад мэдээ button to go to the next page of articles. But once you click there, now you have Previous or Next button which is so unorganized.
How do I fetch all the news articles from websites like these (https://mongolia.mid.ru/en_US/novosti or https://mongolia.mid.ru/ru_RU/)?
It seems that the » Бусад мэдээ button from https://mongolia.mid.ru/ru_RU/ just redirects to https://mongolia.mid.ru/en_US/novosti. So why not start from the latter?
To scrape all the news just go page through page using the link from the Next button.
If you want it to be more programatic, just check the differences in the query parameters and you'll see that _101_INSTANCE_hfCjAfLBKGW0_cur is set to the actual page's number (starting from 1).

Kentico custom page url with URL "Path or Pattern" feature

Updated: As I put in the comment under Brenden's response. I think the issue is not related to multilingual site, but it's with using Properties/ URLs / Path or Pattern feature. After adding value to the field Path of Pattern, the whole navigation stops working properly.
I have a multilingual site (English, French). Currently the URLs are like below:
English: www.domain.com/en-us/contact-us
French: www.domain.com/fr-fr/contact-us
What I want for French is a custom (translated) url www.domain.com/fr-fr/contactez-nous
I followed this Kentico instruction - the bottom part of the page with using Path or Pattern by adding /contactez-nous in the box. Things seem ok, but upon clicking on the page with the new URL on the French site, the whole main navigation (done with Hierarchical Viewer) seems to stuck with that URL; clicking anywhere on the nav doesn't do anything.
Links outside the nav works fine. How to make the nav work again. Thanks for your help!
I think I got it. The GetDocumentURL() is using NodeAliasPath to determine the URL. However, if you have not specified the NodeAliasPath column in the Columns property of the hierarchical viewer, then the current page's NodeAliasPath is used - and thus all items have the same URL. Adding the NodeAliasPath to the Columns property should fix the issue, so the hierarchical viewer has access to the data of each individual item.
EDIT: it looks like that in some cases the DocumentURLPath column must be specified too.
Make sure you're testing this in another browser or even another browser in a private window. If you are testing in a new tab in the same window, the CMS caches the selected language in the Kentico UI and shows that in the browser window.
For instance, if you have selected "French" on the pages app in the bottom left under the content tree, then navigate to your site in a new tab, it will display French no matter how many times you change the language selector on your public site to a new language.
Secondly, check the URL aliases for the given pages in each language. Make sure you don't have an alias that is the same in each language. For instance /contact-us with French and /contact-us in English.

codeigniter making duplicating pages with #! include in link of each page

I have an issue on my website which is on CodeIgniter.
All links are making a duplicate copy of each with #! included in URL
for example
https://www.example.com/port-of-portsmouth
link to a page on my website which is duplicated like the below link
https://www.example.com/port-of-portsmouth#!
Both links have the same page content. How to get rid of this error to avoid content duplication
How to get rid of this error to avoid content duplication
You can't
Because # is used as a fragment identifier. For an example, if the URL is https://example.com/#data this means that open the example.com and jump to a specific section of the page with id"data"
See this URL, https://jestjs.io/docs/en/cli.html#cache
When you open the page, it jumps to cache section.
So, basically, your content is not duplicated, it's just opening the same page and then browser tries to navigate to id !, which might not be there and hence nothing special happens.

hiding sub folders from url display

I have my pages categorized as below....
Main index.html is in the root, so this displays when the domain is entered into a browser.
May pages are categorized as below...
/Pages/Automotive/Ford/Mustang/*.html
/Pages/Automotive/Chevy/Camaro/*.html
/Pages/Automotive/Dodge/Charger/*.html
etc...
What I am looking for is a way to hide the subfolders from the url in the browser..
So, if a link, shortcut, or page is at the following:
/Pages/Automotive/Ford/Mustang/Main.html
The following is displayed in the url status bar on the browser...
/Ford/Mustang/Main.html
or even
/Mustang/Main.html
Basically masking the /Pages/Automotive/ Sub Directories.
And, if a this is entered in the browser:
/Ford/Mustang/Main.html
Then, the original page is still displayed at
/Pages/Automotive/Ford/Mustang/Main.html
Is this doable? If so how, I have looked into .htaccess, but I haven't found what I need..
I am also using 1and1 as my hosting company..

How can I create a separate search page for my blog?

I made a wordpress blog: link text
I have a separate htm page with the form and input field to search. It does not work. But when I have the search field and submit bitton in the sidebar on every page, it works fine. I left bot the sidebar search and the "search blog" page available.
Is it possible to have a separate search page and have the results appear normally?
Your search box is redirecting to the wrong URL
You send the visitor to /blog/?name=(search term)
Should be /blog/?s=(search term)
You can see this if you look at the URL for a search that works (i.e. from your sidebar).

Resources